locked
Windows socket 2 and Windows 8 metro app

    Question

  • I am new to develop network app. I am currently developing metro app for Windows 8. 

    I have a dll that use winsock api to support raw socket. I found out that winsock is not supported on Windows 8 metro app.

    So I am planning to re-write my own dll in C++ using Windows.Networking.Sockets.

    My questions are...

    (1) What is the alternative function to make socket object like below.

    sock = socket(iFamily, iType, iProtocol);

    (2) What is the alternative function to connect.

    connect((SOCKET)sockfd, (SOCKADDR*)&addr, sizeof(SOCKADDR_IN);

    It would be appreciated if someone could provide me samples or webpage I can refer.

    Thanks much!

    Wednesday, August 29, 2012 9:18 PM

All replies

  • Take a look at the the DatagramSocket sample and the StreamSocket sample , depending on what type of socket you need to use.

    Also see Connecting to peers, web and network services for a non-socket specific overview of networking support. Connecting to network services is the socket specific sub-section.

    --Rob

    • Proposed as answer by Jesse Jiang Thursday, August 30, 2012 8:36 AM
    Wednesday, August 29, 2012 9:34 PM
    Owner
  • Thank you Rob,

    Let me ask you with this way. How do I create socket descriptor object using StreamSocket?

    I need to create socket descriptor which I could create using winsock api.

    I need it because....I have a library that accept raw socket and have to pass the socket descriptor that I can create using socket function under winsock.

    Thank you for your help. 

    Thursday, August 30, 2012 12:14 AM
  • StreamSocket does not expose a socket descriptor. The Windows::Networking::Sockets namespace abstracts the connection quite differently from how winsock did. You will need to modify your library not to rely on winsock structures or objects.

    --Rob

    Thursday, August 30, 2012 1:18 AM
    Owner