简单服务器端 /* using System
Data; using System
Sockets; using System
Net; using System
Threading; private static int port = %%2; private static Thread thThreadRead; private static TcpListener TcpListen; private static bool bListener = true; private static Socket stRead; */ private static void Listen() { try { TcpListen = new TcpListener(port); TcpListen
Start(); stRead = TcpListen
AcceptSocket(); EndPoint tempRemoteEP = stRead
RemoteEndPoint; IPEndPoint tempRemoteIP = (IPEndPoint)tempRemoteEP; IPHostEntry host = Dns
GetHostByAddress(tempRemoteIP
Address); string sHostName = host
HostName; while (bListener) { stRead
Send(Encoding
GetBytes(%%1)); string sTime = DateTime
ToShortTimeString(); Byte[] byRead = new Byte[1024]; int iRead = stRead
ReceiveFrom(byRead, ref tempRemoteEP); B