[WebMethod]
public string SendMsgToPort(string ip, int port)
{
IPAddress ipaddress = IPAddress.Parse(ip);//转换IP地址
IPEndPoint ipe = new IPEndPoint(ipaddress, port);
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);//建立连接
s.Connect(ipe);
byte[] bytes = { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 };
s.Send(bytes);
s.Close();
return "";
}
public string SendMsgToPort(string ip, int port)
{
IPAddress ipaddress = IPAddress.Parse(ip);//转换IP地址
IPEndPoint ipe = new IPEndPoint(ipaddress, port);
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);//建立连接
s.Connect(ipe);
byte[] bytes = { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 };
s.Send(bytes);
s.Close();
return "";
}