套接字帮忙 [英] socket help urgent
问题描述
Hello
我正在开发Asyncronous套接字编程"UDP"在回调方法中,我想知道哪个Ip发送给我的消息..请参阅下面的代码
public static void ReceiveCallback(IAsyncResult iar)
{
我想知道哪个服务器向我发送了消息
.AsyncState;
IPEndPoint sender = new IPEndPoint(IPAddress.Any,1234);
EndPoint rep =(EndPoint)sender;
int read = remort.EndReceiveFrom(iar,ref rep);
if (读> 0)
{
_Objsoc k1234.BeginReceiveFrom(data,0,data.Length,0,ref rep,
new AsyncCallback(ReceiveCallback),_ Objsock1234);
}
}
} < br> catch(Exception ex)
{
throw ex;
}
这是我
< BLOCKQUOTE> http://www.devarticles.com/c/a/C-Sharp/Socket-Programming-in-C-sharp-Part-II/1/
Hello
I am working on Asyncronous socket programing "UDP" In the call back method i want to know which Ip has send me the message .. see the code below
public static void ReceiveCallback(IAsyncResult iar)
{
Here I want to know which server has send me the message
try
{
lock (_lock)
{
Socket remort = (Socket)iar.AsyncState;
IPEndPoint sender = new IPEndPoint(IPAddress.Any , 1234);
EndPoint rep = (EndPoint)sender;
int read = remort.EndReceiveFrom(iar, ref rep);
if (read > 0)
{
_Objsock1234.BeginReceiveFrom(data, 0, data.Length, 0, ref rep,
new AsyncCallback(ReceiveCallback), _Objsock1234);
}
}
}
catch (Exception ex)
{
throw ex;
}
It's Me
http://www.devarticles.com/c/a/C-Sharp/Socket-Programming-in-C-sharp-Part-II/1/
这篇关于套接字帮忙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!