? ?
UdpClient?myClient;
????????
Thread?recvThread;
????????
????????
private
?void
?startRecv(
int
?port)
????????
{
????????????
myClient?=?
new
?UdpClient(port);
????????????
recvThread?=?
new
?Thread(
new
?ThreadStart(receive));
????????????
recvThread.Start();
????????
}
????????
????????
private
?void
?stopRecv()
????????
{
????????????
recvThread.Abort();
????????
}
????????
private
?void
?receive()
????????
{
????????????
IPEndPoint?ipEP?=?
new
?IPEndPoint(IPAddress.Any,?0);
????????????
while
?(myClient!=
null
)
????????????
{
????????????????
byte
[]recvBytes?=?myClient.Receive(
ref
?ipEP);
????????????????
if
?(recvBytes.Length?>?0)
????????????????
{
????????????????????
????????????????
}
????????????
}
????????
}
????????
????????
private
?void
?send(
byte
[]sendBytes,
string
?remoteIP,
int
?remotePort)
????????
{
????????????
myClient.Send(sendBytes,?sendBytes.Length,?remoteIP,?remotePort);
????????
}