Associates a local address with a socket.
[ lReturn = ] WsBind ( socket, lLocalPort, vLocalHost )
The WsBind procedure syntax has the following parts:
Name |
Type |
Description |
lReturn |
Long |
Status code. Returns 0 if successful, -1 if failed. |
socket |
Val ASocket |
Handle identifying an unbound socket. |
lLocalPort |
Val Long |
The local port for the socket. |
vLocalHost |
Val Variant |
The local address to be associated with the socket.Address could be Long (for IPv4) or (ATEasy 2024) array of 16 bytes (IPv6) or a string repressing the host address or its IP address. |
The WsBind function is used on an unconnected socket before subsequent calls to the WsConnect or WsListen functions. It is used to bind to either connection-oriented (TCP/IP) or connection-less (UDP) sockets.
vLocalHost can be specified in one of the following ways:
● Long number representing the IPv4 address (Variant with vtI4)
● Array of 16 bytes representing IPv6 address (ATEasy 2024)
● IPv4 String address, i.e. "10.10.1.1" (ATEasy 2024)
● IPv6 String address, i.e. "fe80::9ce6:108:f120:4704" (ATEasy 2024)
The WsBind function is typically used by servers that can have more than one connection request at a time.
! Open a socket:
socket=WsCreate(aWsTcpIp,0)
! Associate a local host with a socket at a local port:
WsBind(socket,lPort,lHost)
! Set the Socket to listen for an incoming connection from a client:
WsListen(socket)
! Attempts to return a readwrite socket to the remote client in twenty seconds:
lSocket2=WsAccept(socket,20000)
WsConnect, WsGetAddress, WsGetAddressName, WsGetName, WsGetNameAddress, WsListen