Question: I learned that Server application makes a ServerSocket in a specific port,

```
ServerSocket ServerSock=new ServerSocket(9000);

```

and client makes a socket connection to the server application,

```
Socket sock=new Socket("127.0.0.1","9000");

```

So client knows the Ip address and port of the server, I'm confused how and when the server gets knowledge about the client. Please help.

Thanx in advance !!!

Answer: 
The server accepts the client with `ServerSock.accept()`. [Here](http://download.oracle.com/javase/tutorial/networking/sockets/clientServer.html) is a tutorial.
Well, the client knows the IP and port of the server to connect.  

The client then tries to connect with the server.  

For this, an ephimeral port will be assigned to the client process so that if the request connection is accepted by the TCP layer of the server's (server is listening and trying to accept connections) machine a client socket will be available to the server with the IP and port of the client.  

So now server nows how to reach back the client.