contents   index   previous   next



Socket remoteHost()

syntax:

socket.remoteHost()

return:

string - The host this socket is connected to, or null if it is not connected.

 

description:

For listening sockets that are only connected to a port, then this method returns null. Otherwise, it returns the name of the remote host, either the server that the socket connected to, or the client from an incoming request. This method can be used to tell whether or not a socket is listening or is connected.

 

see:

#link <sesock>

 

example:

var listenSocket = Socket( 1000 );

 

if( listenSocket != null )

{

  if( listenSocket.ready() )

  {

     var connection = listenSocket.accept();

     if( connection != null )

     {

        // Print out name of incoming request

        Screen.writeln( connection.remoteHost() );

        // .. do other stuff ...

        connection.close();

     }

  }

  listenSocket.close();

}

 


Socket write()