Issues with async receiving UDP Unicast packets in Windows Phone 7

后端 未结 4 1342
你的背包
你的背包 2020-12-19 04:24

I\'m trying to get my Windows Phone 7 Mango app to listen to incoming UDP packets but having a heck of a time. I have the new Beta 2 refresh of the Windows Phone 7.1 SDK and

4条回答
  •  既然无缘
    2020-12-19 05:12

    I found that a strange thing in that "Win7 UDP server" sample that is the server-side UDP socket doesn't "Bind"

    in my experiment, call "ReceiveFromAsync" on a socket which doesn't bind, "invalid argument" exception is throw. After binding before "ReceiveFromAsync", at least "ReceiveFromAsync" won't throw "invalid argument" exception.

    My codes is similar to yours, but there is still some problems. it seems that, I call "ReceiveFromAsync" once, but the OS fire the event callbacks twice, which cause very serious race condition.

    There is so few sample, documents about "UDP + SocketAsyncEventArgs". Maybe I have to revert back to using "BeginReceiveFrom".

提交回复
热议问题