![]() |
subject > component > module > Java module > Java class > ServerSocket 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 module | The Basics of Java | class^2 | |||||
ServerSocket class | Socket clientSocket= new Socket(host, port); | 3.5 - Technology Needed to Build Client-Server Systems | Java class | the 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 port | ServerSocket serverSocket = new ServerSocket(port); where port is the integer representing the port number on which the server should be listening | server socket |
Next Java class: Socket class Up: Java class Previous Java class: Locale class