Introduction
This example shows how to create a Server which listens on port 2000. It’s general purpose and doesn’t do anything yet. You should create your own protocol.
try {
int port = 2000;
ServerSocket srv = new ServerSocket(port);
// Wait for connection from client.
Socket socket = srv.accept();
} catch (IOException e) {
}