moka.io
Class Socket

java.lang.Object
  |
  +--moka.lang.Object
        |
        +--moka.io.IOStream
              |
              +--moka.io.Socket

public class Socket
extends IOStream

This class implements sockets. A socket is an endpoint for communication between two machines.

The actual work of the socket is performed by encapsulating the TIOS link functions.

Since:
MDK1.0a

Field Summary
 int timeout
          The timeout, in 1/20th of second.
 
Fields inherited from class moka.io.IOStream
error, opened
 
Constructor Summary
Socket()
          Creates an unconnected socket.
 
Method Summary
 void close()
          Closes the socket.
 void open()
          Opens the socket for reading and writting.
 char readByte()
          Reads an 8 bit byte.
 void readBytes(moka.io.char_p buffer, short len)
          Copies to a buffer of bytes up to the specified length bytes read from the stream.
 void writeByte(char val)
          Writes an 8 bit byte.
 void writeBytes(moka.io.char_p buffer, short len)
          Writes a buffer of bytes up to the specified length.
 
Methods inherited from class moka.io.IOStream
finalize, readBoolean, readChar, readChars, readDouble, readInt, readLong, readObject, readShort, readString, writeBoolean, writeChar, writeChars, writeDouble, writeInt, writeLong, writeObject, writeShort, writeString
 
Methods inherited from class moka.lang.Object
equals, getClassName, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

timeout

public int timeout
The timeout, in 1/20th of second.

Constructor Detail

Socket

public Socket()
Creates an unconnected socket.

Method Detail

open

public void open()
Opens the socket for reading and writting.

Specified by:
open in class IOStream

close

public void close()
Closes the socket.

Specified by:
close in class IOStream

writeByte

public void writeByte(char val)
Writes an 8 bit byte.

Specified by:
writeByte in class IOStream
Parameters:
val - the byte value to be written

writeBytes

public void writeBytes(moka.io.char_p buffer,
                       short len)
Writes a buffer of bytes up to the specified length.

Specified by:
writeBytes in class IOStream
Parameters:
buffer - the buffer of bytes to be written
len - the specified length

readByte

public char readByte()
Reads an 8 bit byte.

Specified by:
readByte in class IOStream
Returns:
the byte value read

readBytes

public void readBytes(moka.io.char_p buffer,
                      short len)
Copies to a buffer of bytes up to the specified length bytes read from the stream.

Specified by:
readBytes in class IOStream
Parameters:
buffer - the buffer of bytes where the bytes will be copied
len - the specified length