두 메소드 모두 udp socket에 대해서 사용하는 것인데


아주 심각한 버그가 있다.


ReceiveFromAsync() 의 경우 Completed event 발생 후 RemoteEndpoint가 '가끔' 올바르게 설정되지 않는다.


http://stackoverflow.com/questions/5802998/is-this-receivefromasync-bug


이런 현상이다. (내가 쓴 글임)



밑에 답글에 보면 ReceiveMessageFromAsync()과 SocketAsyncEventArgs.ReceiveMessageFromPacketInfo를 쓰라고 되어있는데


SocketAsyncEventArgs.ReceiveMessageFromPacketInfo.Address 는 항상 null 이다!!!!


http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.receivemessagefromasync(v=VS.90).aspx


여기 있는데로

To ensure that all IPPacketInformation objects are valid, an application should set the PacketInformation socket option to true before it is bound to a local endpoint using the SetSocketOption(SocketOptionLevel, SocketOptionName, Boolean) method.

bind 하기 전에 소켓 옵션을 설정해도 안돼!!!


그래서 찾아보니..


ReceiveMessageFromAsync() 버그는 .NET framework 4.0에서 고쳐졌다고 한다.


http://connect.microsoft.com/VisualStudio/feedback/details/543700/net-framework-3-5-socket-receivemessagefrom-leaves-ippacketinformation-empty


아오 빡쳐ㅕ ㅁㄴ이라ㅜㅁㄴ인ㄻㄴㅇ


ReceiveFromAsync() 는 모르겠다. 고쳐졌나? ㅠㅠ




-------------------------------------------------


확인 결과 : ReceiveFromAsync(), ReceiveMessageFromAsync() 의 버그가 닷넷 4.0 에서 모두 fix 되었다.


근데 SocketAsyncEventArgs.ReceiveMessageFromPacketInfo.Address 에는 port가 없다. 으흑흑...

Posted by 휘사마
,