contents   index   previous   next



Socket() with hostname

syntax:

Socket(hostname, port)

where:

hostname - Name of remote host to connect to

 

port - Port of remote host to connect to

 

return:

object - A new Socket object, or null on error

 

description:

This method attempts to connect to the specified remote host. If the library is unable to connect to the remote host, then null is returned and error is set. Once the connection is established, the socket can be read from / written to until it is closed or the connection is lost.

 

see:

#link <sesock>, Socket error()

 

example:

function connect( hostnamePort )

{

   var index;

   var port = 1000;  // Default port

 

   if( (index = hostnamePort.indexOf(":")) != -1 )

   {

      port = ToNumber(hostnamePort.substring(index,

                      hostnamePort.length));

      hostnamePort = hostnamePort.substring(0,index);

   }

 

   var socket = Socket(hostnamePort, port);

 

   return socket;

}

 


Socket() with port