gcspy.comm
Class Client

java.lang.Object
  extended by gcspy.comm.Client

public class Client
extends java.lang.Object

All the socket stuff wrapped up

Author:
Tony Printezis

Constructor Summary
Client(java.net.Socket socket, int maxLen)
          Create a new client
Client(java.lang.String server, int port, int maxLen)
          Create a new client
 
Method Summary
 void close()
          Close the client
 BufferedInput createBufferedInput()
          Create a new input buffered
 BufferedOutput createBufferedOutput()
          Creatre a new output buffer
 void definitelyReceive()
          Receive a stream into the inBuffer
 byte[] getBufferIn()
          Return the input buffer
 byte[] getBufferOut()
          Return the output buffer
 int getLen()
          Return the length of the in/out buffer
 boolean hasTerminated()
          Has the input terminated?
 void receive()
          Receive a stream into the inBuffer
 void send(BufferedOutput output)
          Send a stream
 void send(byte[] buffer)
          Send a stream using a buffer
 void send(byte[] buffer, int len)
          Send a stream using the prefix of a buffer
 void send(int len)
          Send the outBuffer as a stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Client

Client(java.net.Socket socket,
       int maxLen)
 throws java.io.IOException
Create a new client

Parameters:
socket - The socket on which to communicate
maxLen - Maximum buffer size
Throws:
java.io.IOException

Client

public Client(java.lang.String server,
              int port,
              int maxLen)
       throws java.io.IOException
Create a new client

Parameters:
server - The name of the server
port - The port number
maxLen - Maximum length of the stream
Throws:
java.io.IOException
Method Detail

close

public void close()
           throws java.io.IOException
Close the client

Throws:
java.io.IOException

send

public void send(byte[] buffer)
          throws java.io.IOException
Send a stream using a buffer

Parameters:
buffer - The buffer.
Throws:
java.io.IOException

send

public void send(byte[] buffer,
                 int len)
          throws java.io.IOException
Send a stream using the prefix of a buffer

Parameters:
buffer - the buffer to send
len - its length
Throws:
java.io.IOException

send

public void send(int len)
          throws java.io.IOException
Send the outBuffer as a stream

Parameters:
len - the length of the buffer to send
Throws:
java.io.IOException

send

public void send(BufferedOutput output)
          throws java.io.IOException
Send a stream

Parameters:
output - the BufferedOutput to send
Throws:
java.io.IOException

getBufferOut

public byte[] getBufferOut()
Return the output buffer

Returns:
the out buffer

definitelyReceive

public void definitelyReceive()
                       throws java.io.IOException
Receive a stream into the inBuffer

Throws:
java.io.IOException

receive

public void receive()
             throws java.io.IOException
Receive a stream into the inBuffer

Throws:
java.io.IOException

getBufferIn

public byte[] getBufferIn()
Return the input buffer

Returns:
the in buffer

hasTerminated

public boolean hasTerminated()
Has the input terminated?

Returns:
true if len <= 0

getLen

public int getLen()
Return the length of the in/out buffer

Returns:
the lenght

createBufferedInput

public BufferedInput createBufferedInput()
Create a new input buffered

Returns:
a new BufferedInput using the in buffer

createBufferedOutput

public BufferedOutput createBufferedOutput()
Creatre a new output buffer

Returns:
a new BufferedOutput using the out buffer