de.karb.hitcryptoproxy
Class HitSocket

java.lang.Object
  extended by de.karb.hitcryptoproxy.HitSocket

public class HitSocket
extends java.lang.Object

Utility-Class that holds a socket, the socket's outputstream as print stream and the socket's inputstream as buffered reader

Author:
Schildmann@karb.de

Constructor Summary
HitSocket(java.net.Socket pSocket)
          Constructor that creates a HitSocket object for a given socket.
 
Method Summary
 void close()
          closes the socket and its buffered reader and print stream
 void finalize()
           
 void flush()
          Flushes the print stream, if it is not null.
 boolean isClosed()
          Returns the closed state of the socket.
 boolean isConnected()
          Returns the connection state of the socket.
 void print(java.lang.String line)
          Prints a string, if the print stream is not null.
 java.lang.String readLine()
          Reads a line of text of the buffered reader.
 void setSoTimeout(int timeout)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HitSocket

public HitSocket(java.net.Socket pSocket)
          throws java.io.IOException
Constructor that creates a HitSocket object for a given socket. A buffered reader and a print stream are created for the socket's inputstream and outputstream.

Parameters:
pSocket - the given socket
Throws:
java.io.IOException - if an I/O error occurs when creating the output stream or input stream or if the socket is closed or is not connected or if the socket input has been shutdown using Socket.shutdownInput()
Method Detail

close

public void close()
closes the socket and its buffered reader and print stream


readLine

public java.lang.String readLine()
                          throws java.io.IOException
Reads a line of text of the buffered reader. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.

Returns:
A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached or the buffered reader is null
Throws:
java.io.IOException - If an I/O error occurs

print

public void print(java.lang.String line)
Prints a string, if the print stream is not null. If the argument is null then the string "null" is printed. Otherwise, the string's characters are converted into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the PrintStream.write(int) method.

Parameters:
line - The String to be printed

flush

public void flush()
Flushes the print stream, if it is not null. This is done by writing any buffered output bytes to the underlying output stream and then flushing that stream.

See Also:
OutputStream.flush()

isClosed

public boolean isClosed()
Returns the closed state of the socket.

Returns:
true if the socket has been closed or the socket is null

isConnected

public boolean isConnected()
Returns the connection state of the socket.

Returns:
true if the socket successfuly connected to a server

setSoTimeout

public void setSoTimeout(int timeout)
                  throws java.net.SocketException
Parameters:
timeout -
Throws:
java.net.SocketException
See Also:
Socket.setSoTimeout(int)

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable
See Also:
Object.finalize()