Current location - Quotes Website - Collection of slogans - How does the server-side ServerSocket object in Java get the server-side address and port number, and how to get the remote request?
How does the server-side ServerSocket object in Java get the server-side address and port number, and how to get the remote request?
server socket s = new server socket(8888);

while (true) {

//Establish a connection

socket socket = s . accept();

//getnet address () gets the remote ip address, and getPort () is disconnected from the remote client.

"Hello, client address information:"+socket.getnetaddress ()+"\ tClient communication port number:" +socket.getPort ().