Creating a Server Socket



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) {
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.