关于Socket通信怎么做啊
前段时间做串口通信,主要就是一些发送指令,做完后,老板说要用socket通信也做上,用到TCP通信,请问各位要怎么做,有链接也可以。先谢谢大家了。帮顶给分。
------解决方案--------------------顶
------解决方案--------------------http://blog.csdn.net/neusoft06/article/details/9113227
希望能帮到你
------解决方案--------------------100分啊,不错,给你段代码,刚写的~~
#region 监听连接
private void RecConn()
{
tempread = new TcpListener(portId);
tempread.Start();
while (true)
{
Thread.Sleep(2000);
try
{
stRead = tempread.AcceptSocket();
}
catch
{
continue;
}
tempRemoteEP = stRead.RemoteEndPoint;
tempRemoteIP = (IPEndPoint)tempRemoteEP;
tcpConnect = true;
string staIp = tempRemoteIP.Address.ToString();
string staName = IniFile.IniReadValue("集控站IP", staIp, "CenterFlag");
MessageBox.Show(string.Format("{0}站点连接主机", staName));
try
{
thredSendHeart.Start();