日期:2014-05-17 浏览次数:21276 次
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPAddress myIP = IPAddress.Parse("127.0.0.1");//ip
IPEndPoint EPhost = new IPEndPoint(myIP, int.Parse(PubConstant.getLogProductPort)); //端口
socket.Connect(EPhost);
string SendContent = type.ToString() + "," + Status.ToString() + "," + productID + "," + SID.ToString() + "\r\n";
byte[] sendBytes = System.Text.Encoding.UTF8.GetBytes(SendContent);//务必写上\r\n
socket.Send(sendBytes, sendBytes.Length, SocketFlags.None);
byte[] ReceiveMsg = new byte[256];
int k = socket.Receive(ReceiveMsg);
string msg = Encoding.UTF8.GetString(ReceiveMsg);