CaTx
CaTx

Reputation: 1501

C# configuring TCPClient client's port

I have coded TCPClient() in C# to communicate with another device on LAN. I only have to specify the target IP and port number.

Now I am coding something quite similar to it. However, it specifies that the client port from my PC has to be something greater than 1024. How can I configure that? does this mean that VS automatically takes care of that if not specified?

Upvotes: 1

Views: 1425

Answers (1)

user555045
user555045

Reputation: 64913

TcpClient(IPEndPoint) can be used to specify the client port (just use IPAddress.Any for the address part). As documented on Socket.Bind and wikipedia:ephemeral_port, by default a port higher than 1024 would be used.

Upvotes: 2

Related Questions