Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The following sections provide sample code describing how sockets work.

...

BSDNet SockNet AppDescription
socket()NetSock_Open()NetApp_SockOpen()Create a datagram (i.e., UDP) or stream (i.e., TCP) type socket.
bind()NetSock_Bind()NetApp_SockBind()Assign network addresses to sockets.
connect()NetSock_Conn()NetApp_SockConn()Connect a local socket to a remote socket address.
listen()NetSock_Listen()NetApp_SockListen()Set a socket to accept incoming connections.
accept()NetSock_Accept()NetApp_SockAccept()Wait for new socket connections on a listening server socket.
recv() / recvfrom()NetSock_RxData() / NetSock_RxDataFrom()NetApp_SockRx()Copy up to a specified number of bytes received from a remote socket into an application memory buffer.
send() / sendto()NetSock_TxData() / NetSock_TxDataTo()NetApp_SockTx()Copy bytes from an application memory buffer into a socket to send to a remote socket.
close()NetSock_Close()NetApp_SockClose()Terminate communication and free a socket.
select()NetSock_Sel()N/ACheck if any sockets are ready for available read or write operations or error conditions.
N/ANetSock_SelAbort()N/A
Abort a select (i.e. unblock task(s) waiting on socket(s) using the select)

...

BSDµC/TCPIP FunctionsDescription
htonl

NET_UTIL_HOST_TO_NET_32

Convert 32-bit integer values from network-order to CPU host-order.
htons()NET_UTIL_HOST_TO_NET_16()Convert 16-bit integer values from network-order to CPU host-order.
ntohl()NET_UTIL_NET_TO_HOST_32()Convert 32-bit integer values from network-order to CPU host-order.
ntohs()NET_UTIL_NET_TO_HOST_16()Convert 16-bit integer values from network-order to CPU host-order.
inet_addr()NetASCII_Str_to_IPv4()Convert a string of an IPv4 address in dotted-decimal notation to an IPv4 address in host-order.
inet_aton()NetASCII_Str_to_IPv4()Convert an IPv4 address in ASCII dotted-decimal notation to a network protocol IPv4 address in network-order.
inet_ntoa()NetASCII_IPv4_to_Str() Convert an IPv4 address in host-order into an IPv4 dotted-decimal notation ASCII string.

...