Returns the name of the local socket or the remotely-connected socket.
[ sServerName = ] WsGetName ( socket [, bLocal ] )
The WsGetName procedure syntax has the following parts:
Name |
Type |
Description |
sServerName |
BString |
The local name or remote host name for the specified address. |
socket |
Val ASocket |
A descriptor identifying a local or remotely-connected socket. |
bLocal |
Val Bool |
If True, returns a local socket address. If False, returns a remotely-connected socket address. The default value is True. |
If bLocal is set to True, the WsGetName function retrieves the name of the local socket, for example, a datagram socket or a connected socket. If bLocal is set to False, the WsGetName function retrieves the name of the remotely-connected socket only. The WsGetName function will return an empty string if it is unable to retrieve anything.
Note: Calling WsGetName(socket) is the same as calling WsGetAddressName(WsGetAddress(socket)).
The following example will return the name for the specified remote host for the socket handle:
! Open a socket:
socketServer=WsCreate(aWsTcpIp,0)
! Associate a local host with a socket at a local port:
WsBind(socketServer,lPort,lHost)
! Set the Socket to listen for an incoming connection from a client:
WsListen(socketServer)
! Attempts to return a read/write socket to the remote client in twenty seconds:
socketClient=WsAccept(socketServer,20000)
! Get the remote host address:
strName=WsGetName(lSocketClient, False)