When a socket is created with a call to the socket function, it exists in a name space (address family), but it has no name assigned to it. Passing AEE_INADDR_ANY (zero) for the address explicitly requests that the socket be assigned to any local address. Passing AEE_BREW_LOOPBACK allows local connections. Passing a multicast group address can be used for receiving multicast traffic destined to that group, if the selected network is a multicast network, such as MediaFLO or CDMA BCMCS. On other networks, multicast is not supported yet.
NOTE: The ability to bind to a specific local IP address is not presently supported, and the above options are the only valid values for the INAddr parameter. In the case of AEE_INADDR_ANY, the local IP address is assigned automatically by the sockets library.
Also note the possibility of an AEE_NET_WOULDBLOCK result. This typically occurs only in cases where a network connection, such as a PPP link, must be established. In that event, Bind() returns AEE_NET_WOULDBLOCK, and can be called again to obtain the final result (error or success). For notification of when to call Bind() again, the ISOCKET_Writeable() call can be used. (Note that just as with Write(), a ISOCKET_Writeable() callback does not guarantee that a subsequent call to Bind() will complete, so the caller must be prepared to receive AEE_NET_WOULDBLOCK again.)
The user is not required to call Bind() until a non-WOULDBLOCK result is returned. The user can proceed to attempt to connect, send or receive data using ISOCKET_Connect(), ISOCKET_SendTo() or ISOCKET_RecvFrom(), in which case the bind operation (and any network startup) proceeds in the background, and any failure in startup phases is reflected in an ISOCKET_Connect(), ISOCKET_SendTo(), or ISOCKET_RecvFrom() error result.
- pISocket:Pointer to the ISocket Interface object that needs to be connected.
- addr:IP Address.
int ISOCKET_Bind(ISocket * pISocket, INAddr addr, uint16 wPort)
Local address is already in use.
Address family not supported.
Invalid socket descriptor is specified.
Invalid address parameter has been specified.
Socket is already attached to a local name.
Specific local IP address was requested (not supported) or the socket is a TCP socket
No data available now; try again later (See ISOCKET_Readable()).