简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM