locked
Mapping Between winsock2.h and windows.networking.sockets

    Question

  • I am trying to port a desktop app to a metro style app.

    My app use the following functions  under  winsock2.h(which is not compatible in metro style)

     accept() ..........

     bind() .............

     closesocket() ..

     connect() ........

     getpeername()

     getsockname()

     getsockopt() ...

     htonl() ............

     htons()............

     ioctlsocket() .

     listen()..........

     ntohl() ..........

     ntohs()..........

     recv() ...........

     recvfrom() ....

     select() .........

     send() ...........

     sendto() ........

     setsockopt()..

     socket() ..

    Microsoft suggests to use windows.networking.sockets.But unfortunately i didn't find any mapping between winsock2.h and windows.networking.sockets.

    I am studying windows.networking.sockets to find the proper replacement.I find it very difficult to map between winsock2.h and  windows.networking.sockets.

    Is there any mapping and sample code available?

    or I need to study windows.networking.sockets and try to find replacement ?

    Tuesday, July 10, 2012 8:04 AM

Answers

All replies

  • The SteamSocket Sample demonstrates the use of Windows.Networking.Sockets. There is not a 1:1 API mapping between the two. This topic came up in the forums previously. See this post.

    David Lamb

    • Proposed as answer by Jesse Jiang Wednesday, July 11, 2012 7:09 AM
    • Marked as answer by Jesse Jiang Tuesday, July 17, 2012 5:49 AM
    Tuesday, July 10, 2012 3:29 PM
    Moderator
  • I guess, as socket programming  in WINRT become object oriented i  cant find 1:1 mapping of all the winsock2 functions.

    I am looking for the equivalent   accept() and select() of winsock2 in windows.networking.sockets

    How can i get the functionality of those two functions  using  windows.networking.sockets?

    Friday, July 13, 2012 4:28 AM
  • Fahad,

    You won't be able to match every winsock function to a WinRT equivalent, but you should be able to match nearly every bit of functionality. The sample David linked to includes a server component that shows how to set up a listening socket server that can accept connections.


    http://blog.voidnish.com

    Friday, July 13, 2012 1:11 PM