The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.net  [27 examples] > Sockets  [5 examples]

e148. Creating a Server Socket

    try {
        int port = 2000;
        ServerSocket srv = new ServerSocket(port);
    
        // Wait for connection from client.
        Socket socket = srv.accept();
    } catch (IOException e) {
    }

 Related Examples
e147. Creating a Client Socket
e149. Reading Text from a Socket
e150. Writing Text to a Socket
e1071. Sending a POST Request Using a Socket

See also: Datagram    Encodings    HTTP    Hostnames and IP Addresses    Multicast    URLs   


© 2002 Addison-Wesley.