Java ServerSocket accept() methodThe accept() method of ServerSocket class is used to accept the incoming request to the socket. To complete the request, the security manager checks the host address, port number, and localport. SyntaxReturns:The new Socket Throws:IOException- if an I/O error occurs when waiting for a connection. SecurityException- if a security manager exists and its checkAccept method doesn't allow the operation. SocketTimeoutException- If a timeout was previously set with setSoTimeout and the timeout has been reached. IllegalBlockingModeException- If this socket has an associated channel, the channel is in non-blocking mode, and there is no connection ready to be accepted. Example 1Server program: Output: Client Application: Output: Example 2Server Application Output: Client Application Output:
Next TopicJava ServerSocket
|