CS 596: Client-Server Programming
Spring Semester, 1997
Doc 6, Hinges and Servers
To Lecture Notes Index
San Diego State University -- This page last updated Feb 13, 1997
Contents of Doc 6, Hinges and Servers
Socket Library
Java's socket library is simple and easy to use:
- Socket(hostname, portNumber)
- Socket(hostAddress, portNumber)
- close()
- getInputStream()
- getOutputStream()
- getLocalPort()
If your development language or system does not have
such good socket library either buy one or write
Server Architecture
Server with Hinge
Network Interface
ServerSocket acceptor = new ServerSocket(0);
System.out.println("On port " + acceptor.getLocalPort());
while (true)
{
Socket client = acceptor.accept();
clientAction(client.getInputStream(),
client.getOutputStream());
client.close();
}
Application Code
clientAction(InputStream in, OutputStream out)
{
//Work done here
}
Some Possible Hinges