Skip to content

Add OSAL abstraction for closing sockets#48

Open
mzella-ll wants to merge 1 commit into
CiscoDevNet:mainfrom
mzella-ll:feature/add-osal-socket-close
Open

Add OSAL abstraction for closing sockets#48
mzella-ll wants to merge 1 commit into
CiscoDevNet:mainfrom
mzella-ll:feature/add-osal-socket-close

Conversation

@mzella-ll

Copy link
Copy Markdown

Summary

This PR extends the OSAL socket interface with a wrapper for closing sockets.

The OSAL already provides osal_socket() for opening sockets. This PR adds the corresponding osal_socket_close() function and uses it in the CoAP client/server code instead of calling close() directly.

Changes

  • Add osal_socket_close() declaration to osal/osal.h.
  • Implement osal_socket_close() for:
    • Linux
    • FreeRTOS
    • EFR32 Wi-SUN
  • Replace direct close() calls in:
    • src/coap/coapclient.c
    • src/coap/coapserver.c
  • Correct the documentation of osal_socket() to state that it returns a socket descriptor on success.

Motivation

Socket creation is already abstracted through OSAL via osal_socket(), but socket cleanup was still performed directly with close().

Adding osal_socket_close() makes the socket lifecycle consistently platform-independent:

osal_socket(...)
osal_socket_close(...)

This improves portability and keeps platform-specific socket handling inside the OSAL backend implementations.

Related issue

Fixes #47

- Add OSAL wrapper for closing sockets
- Use OSAL socket close wrapper in CoAP

@manojnacsl manojnacsl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good - approved.

  • Please check build/sanity for all the impacted platforms to ensure no build breakage.
  • Close #47 after merging this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add OSAL abstraction for closing sockets

2 participants