try
{
IPAddress MyIP = IPAddress.Parse(“127.0.0.1″);
TcpListener MyListener = new TcpListener(MyIP, Convert.ToInt16(“1235″));
MyListener.Start();
Socket MySocket = MyListener.AcceptSocket();
byte[] MyData = new byte[256];
MySocket.Receive(MyData);
this.richTextBox1.AppendText(System.Text.Encoding.Unicode.GetString(MyData));
UnicodeEncoding MyInfo = new UnicodeEncoding();
MySocket.Send(MyInfo.GetBytes(“From Server:你好!我是服务器”));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,“信息提示”,MessageBoxButtons.OK,MessageBoxIcon.Information);
}
try
{
TcpClient MyClient = new TcpClient();
MyClient.Connect(“127.0.0.1″, Convert.ToInt16(“1235″));
Stream MyStream = MyClient.GetStream();
UnicodeEncoding MyInfo = new UnicodeEncoding();
byte[] MyData = new byte[256];
byte[] MySendByte = MyInfo.GetBytes(“From Client:你好!我是客户端”);
MyStream.Write(MySendByte, 0, MySendByte.Length);
MyStream.Read(MyData, 0, 256);
this.richTextBox1.AppendText(System.Text.Encoding.Unicode.GetString(MyData));
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,“信息提示”,MessageBoxButtons.OK,MessageBoxIcon.Information);
}
try
{
SqlConnection MyConnect = new SqlConnection(m_ConnectionStrings);
//插入新纪录
string MySQL = string.Format(“INSERT INTO [BSM_SystemServiceInfoTable] VALUES ({0},N'{1}',N'{2}',N'{3}',N'{4}')”,AgentID, data[1], data[2], data[3], data[0]);
MyCommand = new SqlCommand(MySQL, MyConnect);
MyCommand.Connection.Open();
MyCommand.ExecuteNonQuery();
MyCommand.Connection.Close();
}
catch (System.Exception e)
{
MessageBox.Show(e.ToString ());
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有