這些天由於有個p
下面將我自己的代碼貼出來
using System;
using System
using System
using System
using System
using System
namespace UDPChat
{
class Program
{
private static IPAddress remoteAddress;
private static int remotePort;
private static int localPort;
[STAThread ]
static void Main(string[] args)
{
try
{
Console
localPort = Convert
Console
remotePort = Convert
Console
remoteAddress = IPAddress
Thread tRec = new Thread(new ThreadStart(Receiver));
tRec
while (true)
{
Send(Console
}
}
catch (Exception ex)
{
Console
}
}
private static void Send(string p)
{
UdpClient sender = new UdpClient();
IPEndPoint endPoint = new IPEndPoint(remoteAddress
try
{
byte[] bytes = Encoding
sender
}
catch (Exception ex)
{
Console
}
finally
{
sender
}
}
public static void Receiver()
{
UdpClient receivingUdpClient = new UdpClient(localPort);
IPEndPoint remoteiendpoint = null;
try
{
Console
while (true)
{
byte[] receivedBytes = receivingUdpClient
string returnData = Encoding
Console
}
}
catch (Exception ex)
{
Console
}
}
}
}
由於是一個聊天程序
From:http://tw.wingwit.com/Article/program/net/201311/13800.html