C# - Sending and Receiving a TCP/IP message to an IP Address and Port

前端 未结 1 1244
终归单人心
终归单人心 2021-01-06 15:51

I have the following code to send a TCP/IP message to a specific IP Address and Port:

public bool sendTCPMessage(string ip_address, string port, string trans         


        
相关标签:
1条回答
  • 2021-01-06 16:12

    You'd need a TcpListener object to act as the server. The TcpListener object would listen for incoming connections on the specified port. You can use the .AcceptTcpClient method to establish a new connection. (If you wanted multiple clients you'd have to look into multithreading)

    Also as a side note using Port 1 would be bad practice, low port numbers are usually reserved for system stuff or standard protocols such as telnet, ftp, http etc.

    0 讨论(0)
提交回复
热议问题