using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Sockets;
using System.Net;
namespace KEYENCE90340;
class Program
{
static Socket ClientSocket;
static void Main(string[] args)
{
String IP = "192.168.100.100";
int port = 9004;
IPAddress ip = IPAddress.Parse(IP); //将IP地址字符串转换成IPAddress实例
ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);//使用指定的地址簇协议、套接字类型和通信协议
IPEndPoint endPoint = new IPEndPoint(ip, port); // 用指定的ip和端口号初始化IPEndPoint实例
ClientSocket.Connect(endPoint); //与远程主机建立连接
Console.WriteLine("开始发送消息");
WriteMessage("开始发送消息。" + DateTime.Now);
byte[] message = Encoding.