Class jls.net.Socket

This class represents a client TCP socket. A socket is an endpoint for communication between two machines. TCP (Transmission Control Protocol) is a connection-oriented, reliable byte-stream protocol of the TCP/IP protocol suite.
Defined in: Socket.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
jls.net.Socket(host, port)
Creates a TCP socket.
Method Summary
Method Attributes Method Name and Description
 
Closes this socket.
 
Adjusts this socket's blocking mode.
 
connect(endpoint)
Connects this socket to the server.
 
Flushs this socket.
 
read(buffer)
Reads a sequence of bytes from this channel into the given buffer.
 
Reads a byte.
 
readByteArray(barray, offset, length)
Reads bytes into the specified byte array, starting at the given offset.
 
write(buffer)
Writes a sequence of bytes to this channel from the given buffer.
 
Writes a byte.
 
writeByteArray(barray, offset, length)
Writes bytes from the specified byte array starting at the given offset.
Class Detail
jls.net.Socket(host, port)
Creates a TCP socket.
Parameters:
{String} host Optional
The host name to connect to, could be a jls.net.InetAddress.
{Number} port Optional
The port number to connect to.
Method Detail
{jls.net.Socket} close()
Closes this socket.
Returns:
{jls.net.Socket} This socket.

{jls.net.Socket} configureBlocking(block)
Adjusts this socket's blocking mode.
Parameters:
{Boolean} block
Whether the socket is placed in blocking mode.
Returns:
{jls.net.Socket} This socket.

{jls.net.InetSocketAddress} connect(endpoint)
Connects this socket to the server.
Parameters:
endpoint
Returns:
{jls.net.InetSocketAddress} The socket address of the server.

{jls.net.Socket} flush()
Flushs this socket.
Returns:
{jls.net.Socket} This socket.

{Number} read(buffer)
Reads a sequence of bytes from this channel into the given buffer.
Parameters:
{jls.lang.Buffer} buffer
The buffer into which bytes are to be transferred.
Returns:
{Number} The total number of bytes read.

{Number} readByte()
Reads a byte.
Returns:
{Number} The unsigned byte or -1.

{Number} readByteArray(barray, offset, length)
Reads bytes into the specified byte array, starting at the given offset.
Parameters:
{ByteArray} barray
The destination byte array.
{Number} offset
The offset at which to start storing bytes.
{Number} length
The maximum number of bytes to read.
Returns:
{Number} The total number of bytes read.

{Number} write(buffer)
Writes a sequence of bytes to this channel from the given buffer.
Parameters:
{jls.lang.Buffer} buffer
The buffer from which bytes are to be retrieved.
Returns:
{Number} The number of bytes written.

{Boolean} writeByte(b)
Writes a byte.
Parameters:
{Number} b
The byte to write.
Returns:
{Boolean} true if the byte has been write.

{Number} writeByteArray(barray, offset, length)
Writes bytes from the specified byte array starting at the given offset.
Parameters:
{ByteArray} barray
The source byte array.
{Number} offset
The offset at which to start getting bytes.
{Number} length
The maximum number of bytes to write.
Returns:
{Number} The number of bytes written.

Documentation generated by JsDoc Toolkit 2.3.2 on Sat Jan 08 2011 02:00:14 GMT+0100 (CET)