
The BIND command can be used to bound TCP and UDP sockets explicitly to a specific network interface. This is only useful on configurations that have more than one network interface enabled. BIND requires two arguments. The first one is the socket handle and the last one is a number which specifies the network interface. These values are currently defined:
1 Is the Ethernet interface
0 Is the WLAN interface
-1 means "all interfaces". This is the default value for new sockets
The following example puts a socket into listen state and binds it to exclusively to the WLAN interface. This prohibits ethernet clients from connecting to that socket.
listen 101,123,0 bind 101, 0
BIND sets LASTERR to ERR_OK (0) on success or any other value on failure. BIND can be used regardless of socket state. A socket can be bound or unbound even it is connected or closed (which makes very less sense). The default binding (-1 = unbound) enables listening sockets to listen on both, and also connecting sockets to send their requests over both interfaces. Same applies to UDP sockets, which work on both interfaces in parallel if binding is removed by calling BIND with -1. A socket loses its binding when it is closed. Please see also the CONNECT, LISTEN and UDPLISTEN pages.