Object Oriented Software Engineering   View all facts   Glossary   Help
subject > component > module > Java module > Java class > ServerSocket class
Next Java classSocket class    UpJava class    Previous Java classLocale class   

ServerSocket class comparison table
Subject have example of connecting is a kind of is a subtopic of is an instance of have example of accepting a connection have purpose have example of listening see also
Java class Java moduleThe Basics of Java    class^2
ServerSocket classSocket clientSocket= new Socket(host, port); 3.5 - Technology Needed to Build Client-Server SystemsJava classthe server must have a thread constantly listening for connections using a statement like the following, embedded in a loop:
Socket clientSocket = serverSocket.accept();
The above statement will wait indefinitely in the accept method until a client tries to connect, then it will try to create an instance of Socket class to handle the new connection. If this is successful both client and server now have instances of Socket class and can communicate freely with each other.
to allow a server to listen to a portServerSocket serverSocket = new ServerSocket(port);
where port is the integer representing the port number on which the server should be listening
server socket

Next Java classSocket class    UpJava class    Previous Java classLocale class