本文介绍了套接字访问非公共成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Hello 我正在开发Asyncronous套接字编程"UDP" 当你右键点击iar时,我想访问((System.Net.Sockets.OverlappedAsyncResult)(iar))。m_SocketAddress。它是非公开成员。 public static void ReceiveCallback(IAsyncResult iar ) {我想要知道哪个服务器向我发送了消息 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; } 这是我解决方案  Hello            I am working on Asyncronous socket programing "UDP" I want to access ((System.Net.Sockets.OverlappedAsyncResult)(iar)).m_SocketAddress when you rightclick on iar. it is a non public member.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 解决方案 这篇关于套接字访问非公共成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-18 20:38