History: ip_socket

This page describes all changes made to the ip_socket package, the TCP/IP Sockets Interface module, since its release.


4.18 (2021-07-11, 18:00):

  • SOCK_AUTO_ENTER_TASK option did not work for: socket_gethostbyname()socket_gethostbyaddr(), socket_inet_ntoa() and socket_get_errno().

4.17 (2021-06-17, 18:15):

  • Fixed compilation issue when TCP is not used (that is, IP_TCP_ENABLE is set to 0).

4.16 (2021-05-17, 19:21):

  • During initialization of the socket module an event could be set (potentially causing a hard fault), if the environment doesn't initialize global variables to zero. This is now fixed.

4.15 (2021-05-04, 19:00):

  • Introduced socket_read() and socket_write() API wrappers for socket_recv() and socket_send().
  • Introduced socket_getsockname() and socket_getpeername() API functions to retrieve the socket and peer IP address and port number.
  • Introduced SOCK_AUTO_ENTER_TASK configuration option to avoid calling ip_enter_task() (and ip_exit_task()) from tasks invoking socket APIs.

4.14 (2021-02-16, 15:00)

  • Corrected setting of event in notification callback function from TCPIP Stack. Previously it could refer to NULL pointer if closing the connection and processing a received frame was done simultaneously.
  • Added SOCKET_SO_SNDBUF to set maximal number of buffers that can be waiting for acknowledgment

4.13 (2021-01-28, 12:15)

  • IP buffer could get stuck at the socket layer if a TCP connection socket was holding it (not all data received in an IP buffer was consumed using socket_recv()) and remote peer closed the connection in parallel to socket_close() invoked by the user.

4.12 (2020-11-25, 9:12)

  • Corrected SOCKET_FD_CLR (non-deleted entry could remain duplicated in the list).

4.11 (2020-09-16, 10:30)

  • Added setting of TCP accept timeout to INFINITE on initialization of a TCP port socket.

4.10 (2020-08-24, 08:50)

  • Fixed socket_select() to correctly recognize port connection so as to be able to detect incoming connections.

4.9 (2020-06-23, 13:10):

  • Added new return value for filter callback (SOCKET_FILTER_DROP) which allows module to silently drop a received SYN packet, instead of replying with a reset frame.

4.8 (2020-05-20, 22:31):

  • MISRA-C:2012: violations eliminated (MISRA-C:2004 revoked).
  • gethostbyname(): if IP address is passed then it will output the same value, without trying to resolve it.
  • socket_select() doesn't return error if a closed socket is present in the exceptfds, it will place to exceptfds ready list.
  • socket_sockaddr structure size increased to be able to hold socket_sockaddr_in6 if IP_V6_ENABLE is set.
  • socket_setopt(): SOCKET_SO_FILTER_CB set socket option added to request for a call-back for a listening TCP connection in order to accept or reject a client connection request.
  • socket_setopt() and socket_getopt(): option level SOCKET_IPPROTO_IPV6 added with SOCKET_IPV6_V6ONLY to be able to accept/reject IPv4 connections on a socket with AF_INET6 domain.
  • socket_open() takes domain parameter into account to be able to accept only IPv4/IPv6 connections (AF_INET/AF_INET6).

4.7 (2019-11-25, 15:57):

  • MISRA-C:2004: violations eliminated

4.6 (2019-07-10, 17:39):

  • Include route.h in socket.c when SOCK_SENDTO_IPV4_BCAST_TO_ALL_INTERFACES is enabled to avoid compilation issues.

4.5 (2019-06-04, 19:00):

  • Added SOCK_SENDTO_IPV4_BCAST_TO_ALL_INTERFACES configuration option. If this is enabled DGRAM packets with global broadcast address destination are sent to all active interfaces.

4.4 (2019-02-13, 16:55):

  • MISRA-C:2004: violations eliminated.

4.3 (2019-01-21, 15:25)

  • Corrected setting of receive sockets in socket_select() for non-blocking connection.
  • Corrected setting of POLLIN flag in socket_poll() for non-blocking connection.
  • POLLHUP and POLLNVAL flags are always set if they occur.
  • socket_recv() now returns 0 if connection is disconnected.

4.2 (2018-09-21, 12:40):

  • SOCK_ERRNO_VARIABLE_NAME option can be defined by user.
  • Compiler error was eliminated which occurred when OS was used and SOCK_TASK_ERRNO was configured to 0.
  • Added socket_inet_addr() function.

4.1r2 (2018-08-29, 18:14):

  • Document HTML link added to the documentation folder.
  • History and document files renamed to the package name.

4.1 (2018-02-20, 11:23):

  • Defines and type names were changed to avoid conflict with native socket implementations.
  • socket_bind(): uninitialized variable may lead to incoming broadcast messages being dropped.

3.35 (2017-11-16, 09:08):

Bug appeared in 3.31 was fixed: soBcket_sendto() can handle packets larger than MTU.

3.34 (2017-10-27, 11:13):

  • Added support for new socket options:

      SO_KEEPALIVE - TCP only: enables/disables TCP keep-alive mechanism.

      SO_BROADCAST - UDP only: enables/disables broadcast datagrams (broadcast datagrams are not prohibited -> no functional change).

      SO_REUSEADDR - TCP/UDP : enables/disables SO_REUSEADDR (stack already behaves accordingly -> no functional change).

      SO_NODELAY   - TCP only: enables/disables TCP NO_DELAY (stack does not use Nagle's algorithm -> no functional change).

3.33 (2017-10-16, 15:00):

  • Added auto port binding after first send of DGRAM.
  • Added (void) casts to oal_mutex_get()/oal_mutex_put().
  • Added check to prohibit multiple socket_bind on a single DGRAM.

3.32 (2017-10-10, 13:20):

  • Added flag SOCK_NCLOSE that indicates that TCP connection already received IP_NTF_CON_CLOSE, IP_NTF_CON_ABORT notification. TCP sockets are now closed correctly when peer disconnects first.

3.31 (2017-10-02, 08:05):

  • socket_sendto() can send zero length packet.
  • UDP port can be opened for specific IP address.

3.30 (2017-09-11, 15:30)

  • TCP socket is not reused if the related TCP connection is not finally closed.


  • tcp_accept() timeout is now controlled by SO_RCVTIMEO.
  • tcp_connect() timeout is now controlled by SO_SNDTIMEO.
  • socket_recv()/socket_recvfrom() now correctly sets error code when socket is closed during execution of function.
  • socket_gethostbyname() now adds terminating null character to h_name.
  • Corrected compilation warnings.


  • Corrected gethostbyname() to get only IPv4 addresses.


  • Corrected calling of ip_addr_to_str() in socket_inet_ntoa().
  • Added NULL pointer check for input value p_arg in socket_ioctl().
  • Corrected exclusion of socket_inet_aton(), socket_inet_ntoa() when IPv4 is disabled.


  • Corrected compilation warnings.


  • An error was fixed in socket_addrst2ipport() which prevented socket_sendto() sending data.


  • socket_poll() and socket_select() functions could only recognize the first connection on a listening socket.


  • added IPv6 support.
  • updated to work with TCP major version 6.
  • updated to work with UDP base major version 6.
  • updated to work with IP base major version 6.


  • updated to work with TCP major version 5
  • updated to work with IP base major version 5.
  • socket_bind() can be called before socket_connect() to define a local port for the STREAM sockets.


  • SO_LINGER option was implemented: socket_close() waits for completion of sending TCP packets before disconnecting to prevent data loss.


  • select and poll are waiting for connection on unconnected sockets in the socket descriptors selected for incoming transfers.


  • select and poll could have been waken up incorrectly indicating no events (when waiting for received packets and transmission was complete on the socket).
  • select could incorrectly set a readfd if only exceptfd occurred.
  • select could return incorrect exceptional descriptor.


  • SO_RCVINFOEN and SO_RCVINFO non-standard options added. These options are only available if SOCK_RCV_INFO_ENABLE configuration option is enabled.


  • Socket layer could lockup if an event occurred on a UDP/TCP socket during a call to: socket_setopt() for ADD_MEMBERSHIP/DROP_MEMBERSHIP, socket_close() for a UDP socket with multicast membership, socket_ioctl() with FIONREAD command, socket_select() and socket_poll()
  • socket_poll()/socket_select() could keep waiting forever if the examined socket(s) was closed.
  • Event receive reorganized to avoid unexpected event reception from the caller task with some RTOSes.


  • FIONREAD ioctl returns now the correct amount of unread bytes, before it reported the amount of unread bytes in the socket layer.
  • Updated to work with UDP major version 5 and TCP major version 4.


  • Required package version checks added.


  • socket_bind() accepts any IP address (not just IN_ADDR_ANY)
  • socket_get_errno() returns SOCKET_SUCCESS in case the errno is set because the task was not registered with ip_enter_task().


  • Changed to use the new tcp_get_buf() and udp_get_buf() function formats.


  • include psp_string.h from api_ip_socket.h to have prototype for psp_memset() used at FD_ZERO.


  • In non-blocking mode socket_accept() exhausted all socket entries if there was an existing connection for that port.
  • Connections established with socket_accept() could sometime incorrectly return an error.


  • socket_close() didn't drop multicast group memberships memberships.


  • socket_inet_ntoa and socket_inet_aton functions added.
  • socket_htons, socket_htonl, socket_ntohs and socket_ntohl functions added for compatibility reasons.
  • socket_gethostbyname and socket_gethostbyaddr functions added.
  • socket_ioctl function added.
  • SO_PRIORITY socket option added.
  • set base port number for DGRAM sockets to be able to use sendto without bind.
  • In socket_recv and socket_recvfrom return code changed to SOCKET_ERROR (-1) in case no data is available and set errno to EAGAIN.
  • changed to use new udp_send function.
  • poll/select didn't report frames arrived right after socket_accept, causing an erroneous situation that poll/select was blocking and waiting for incoming data while it was already available.
  • aborted connections were not reported causing the socket left in open state (there was no indication that socket_close needs to be called).
  • An accepted and closed connection could corrupt the following accepted connections.


  • Warning removed in case IP_UDP_ENABLE is not set in config_ip.h.


  • Removed MTU size packet setting from socket_sendto() and socket_send() when getting a buffer.


  • Comments fixed.


  • Third parameter of get_free_socket() call in socket_accept(): set to 0 instead of NULL (warning eliminated).


  • listen didn't return error if backlog was a negative number only when it was zero.
  • send, sendto, recv, recvfrom also returns error if length is a negative number not only when it's zero.
  • set errno to EPERM in socket_get_errno if the task is not registered.


socket_get_errno return error if the output parameter is NULL


  • socket_get_errno() introduced, this function gives back task specific error codes.
  • socket functions will return -1 and set global error code to EBADF if socket number is valid but it is not opened.


  • select/poll didn't return if FIN was received.
  • poll could cause a crash if used with socket that was created due to an accepted connection.
  • SOCK_DGRAM socket close fixed (was not closed properly)
  • socket_accept returned 0 even if no more entries were available


  • all functions renamed to avoid conflicts with standard function. "socket_" prefix has been added to all functions except for: socket -> socket_open, getsockopt -> socket_getopt and setsockopt -> socket_setopt.


multi-interface compliant


  • needless error numbers removed from API.


  • incorrect close function behavior if accept was not called after listen.
  • comments added


  • Initial release