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).
Field Summary |
private int |
MAXPORT
|
private int |
port
|
private java.net.ServerSocket |
sock
|
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,
registerNatives,
toString,
wait,
wait,
wait |
sock
private java.net.ServerSocket sock
port
private int port
MAXPORT
private final int MAXPORT
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.
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.