API Reference | developer.brewmp.com API Reference | developer.brewmp.com


API Reference


Brew Release
Brew MP 1.0.2
See Also
This function associates a local address and port with the socket. The bind function is used on an unconnected socket.
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.
Pointer to the ISocket Interface object that needs to be connected.
IP Address.
  •     int ISOCKET_Bind(ISocket * pISocket, INAddr addr, uint16 wPort)
  • AEE_NET_SUCCESS: if successful. AEE_NET_ERROR: on error. AEE_NET_WOULDBLOCK: if operation is blocked. call ISOCKET_Writeable() and ISOCKET_Bind() when the callback occurs.
Side Effect
  • None.
The specific error code can be retrieved by calling ISOCKET_GetLastError(). One of the following error codes is returned: AEE_NET_EADDRINUSE Local address is already in use. AEE_NET_EAFNOSUPPORT Address family not supported. AEE_NET_EBADF Invalid socket descriptor is specified. AEE_NET_EFAULT Invalid address parameter has been specified. AEE_NET_EINVAL Socket is already attached to a local name. AEE_NET_EOPNOTSUPP Specific local IP address was requested (not supported) or the socket is a TCP socket AEE_NET_GENERAL_FAILURE General failure. AEE_NET_WOULDBLOCK No data available now; try again later (See ISOCKET_Readable()).