CiaoJava
Class PLServerSocket

java.lang.Object
  |
  +--CiaoJava.PLServerSocket

public class PLServerSocket
extends java.lang.Object

This class creates a server socket and keeps it listening at socket port #5000 (or number given in constructor).


Constructor Summary
PLServerSocket()
          Server socket creation.
 
Method Summary
 int getPort()
          Returns de port number on which the PLServerSocket object is listening.
protected static java.io.BufferedReader getReader(java.net.Socket s)
          Returns the BufferedReader input stream for this socket connection.
protected static java.io.PrintWriter getWriter(java.net.Socket s)
          Returns the PrintWriter output stream for this socket connection.
 java.net.Socket openSocket()
          Accepts a client request for this socket port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PLServerSocket

public PLServerSocket()
               throws java.io.IOException
Server socket creation. Creates a new server socket at port 5000 or higher, and prints the port # at the standard output. When the openSocket() method be called, the object will be listening at this port number for connections.
Parameters:
out - PrintStream on which prints the socket port where the TCP server will work.
Method Detail

openSocket

public java.net.Socket openSocket()
                           throws java.io.IOException
Accepts a client request for this socket port.
Returns:
A Socket object that represents the connection accepted.

getReader

protected static java.io.BufferedReader getReader(java.net.Socket s)
                                           throws java.io.IOException
Returns the BufferedReader input stream for this socket connection. If the socket isn't opened, returns null.
Parameters:
s - Socket object from which the stream reader is to be obtained.
Returns:
the BufferedReader object that represents the reader of the socket received as argument.

getWriter

protected static java.io.PrintWriter getWriter(java.net.Socket s)
                                        throws java.io.IOException
Returns the PrintWriter output stream for this socket connection. If the socket isn't opened, returns null.
Parameters:
s - Socket object from which the stream writer is to be obtained.
Returns:
the PrintWriter object that represents the writer of the socket received as argument.

getPort

public int getPort()
Returns de port number on which the PLServerSocket object is listening.
Returns:
the port number on which the PLServerSocket object is listening.