public void connect()
{
//1.创建socket
Socket tcpClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
//2.发起建立链接的请求
IPAddress ipaddress = IPAddress.Parse("192.168.0.112");
EndPoint point = new IPEndPoint(ipaddress, 7788);
tcpClient.Connect(point);
byte[] data = new byte[1024];
int length = tcpClient.Receive(data);
string message = Encoding.UTF8.GetString(data,0,length);
tcpClient.Send(Encoding.UTF8.GetBytes("1"));
}
C#客户端
最新推荐文章于 2022-12-06 22:55:31 发布