> When a server listens to connection requests from clients, can a
> server choose any port number above 1023 randomly? Or does it needs
[quoted text clipped - 3 lines]
> So in essence does a client send request on a server's specified
> port and the server listens on the same port?
The server listens to a specific port. The connection is established
when a client connects to that port. So although it doesn't matter
what port the server chooses, it must be known to the client in
advance. For that reason, most common services are on "well known"
port numbers. For your own applications you can choose any free port
above 1023, and it's sufficient that your clients know which port
you've chosen.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
geek - 05 Nov 2005 19:20 GMT
Thanks Gordon for the help.
That solves all problems I have been having.
geek - 06 Nov 2005 19:00 GMT
So that also means that server doesn't need to know Client's address?
Then how does it sends reply to client?
Thanks for help.
Gordon Beaton - 06 Nov 2005 18:25 GMT
> So that also means that server doesn't need to know Client's
> address? Then how does it sends reply to client?
The server doesn't need to know the client address in order to reply.
The Socket that was created when the server accepted the client
connection contains the information necessary to reach the client. The
server just sends replies using that Socket.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Roedy Green - 06 Nov 2005 23:21 GMT
>So that also means that server doesn't need to know Client's address?
>Then how does it sends reply to client?
please read http://mindprod.com/jgloss/tcpip.html
it explains that.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
>I have a question regarding TCP/IP socket programming.
You might like to read this background on TCP/IP. It should clear this
up and similar mysteries.
See http://mindprod.com/jgloss/tcpip.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.