Windows Dev Center

Windows.Networking.Socket - How to get read/write events?


  • This is regarding Windows::Networking::Socket namespace. I see in SimpleSocket sample how we used SocketStream, InputStream, and OutputStream, etc.

    In my legacy app, where I use WIN32 socket, I detect read/write events of a connected socket and dispatch the event to corresponding event listeners. In particular, I use this Win32 api:

    DWORD WSAWaitForMultipleEvents(
      __in  DWORD cEvents,
      __in  const WSAEVENT *lphEvents,
      __in  BOOL fWaitAll,
      __in  DWORD dwTimeout,
      __in  BOOL fAlertable

    Now in Metro App I do not have this api. But I want somehow detect the read and write events on the SocketStream. How?

    SocketStreamListener seemingly gives ConnectionReceived event.  Is there any event somewhere something like DataRead/DataWritten event, using which I would know my socket has read or written some data, and then I can tell my corresponding event-listeners what to do.

    Please advise.

    • แก้ไขโดย Shafiq2012 4 พฤษภาคม 2555 15:47
    4 พฤษภาคม 2555 15:44