com.zerjio.JIRC
Class IRCConnection

java.lang.Object
  extended bycom.zerjio.JIRC.IRCConnection

public class IRCConnection
extends java.lang.Object

A class that allows the basic communication between an IRC Client and an IRC Server. It can connect and disconnect from the server, and it can read and write.


Constructor Summary
protected IRCConnection(java.lang.String server, int port)
          Creates a connection between the IRC Client and a specified IRC Server, which can be used to read() and write(...)
 
Method Summary
protected  void disconnect()
          Turn off the connection, not allowing more writings nor readings.
protected  boolean isClosed()
          Checks if the connection is closed.
protected  byte[] read()
          Reads the available bytes sent by the server.
protected  boolean write(byte[] msg)
          Sends information to the IRC Server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IRCConnection

protected IRCConnection(java.lang.String server,
                        int port)
                 throws java.io.IOException
Creates a connection between the IRC Client and a specified IRC Server, which can be used to read() and write(...) to it.

Parameters:
server - The server name, or null for the loopback address.
port - The port number.
Throws:
java.io.IOException - if there was a problem when trying to connect to the IRC server.
See Also:
read(), write(byte[] msg)
Method Detail

isClosed

protected boolean isClosed()
Checks if the connection is closed.

Returns:
true if the connection is closed (no further writing nor reading). false if the connection is NOT closed (writing and reading allowed).

disconnect

protected void disconnect()
                   throws java.io.IOException
Turn off the connection, not allowing more writings nor readings.

Throws:
java.io.IOException - if there was an error when disconnecting.

read

protected byte[] read()
Reads the available bytes sent by the server.

Returns:
The available bytes sent by the server, or null if there are no available bytes.

write

protected boolean write(byte[] msg)
Sends information to the IRC Server.

Parameters:
msg - The bytes that must be send to the IRC Server.
Returns:
true if the message were sent without problem false if there was some error sending the message.