C# socket application :
Ther server is runing on a dedicated port and client obtain connection to it along with the server IP adr. When I'm writing out information about the connection on serverside, i can see the client IP adress as well as the port used at client. I have not spesified any dedicated port
to use on client side, guess it just pick a port not in use from the free range IP ports.
Using Async socket comunication, data transpher both ways.
The question: How can I controll the port in use on clientside when establish the connection against server ?
but I have so far not been able to take kontrol on client side port to bee used in the socket session
Tanks to contribution!
Arne SolhaugPosted Apr 10, 2006, 4:35 AM
I have got it supported in constructor of TcpClient:
On TcpClient, spesify local endpoint before obtaining the connection to server
snippet:
...
//local endpoint
IPAddress ipAddress = Dns.Resolve (Dns.GetHostName ()).AddressList[0];IPEndPoint ipLocalEndPoint = new IPEndPoint (ipAddress, port); //
_socket = new TcpClient(ipLocalEndPoint);
//do connect server
_socket.Connect(ServerAdr,4990);
...