Sockets. How to change the port that is assigned automatically onthe client

  • Thread starter Thread starter LEM
  • Start date Start date
L

LEM

Hi all,

When a client tries to connect to a server, a random port number
is assigned to the client that will be used for the communication with
the server (typically the next free port above 1024). As far as I know
this port is chosen before connecting to the server.

I need to be able to specify a fixed port number there, instead of
letting the system to choose it. Does anybody know how to do it in
C#.

This is what I'm using for connecting

tcpClient = new TcpClient();
tcpClient.BeginConnect(SERVERIP, SERVERPORT, CALLBACKFUNTION, this);

Thanks a lot!
 
Vadym, thanks a lot!! I really appreciate your help.
That's exactly what I need.

Regards
 
Back
Top