Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Contrast "socket API" and "WSASocket API"

Contrast "socket API" and "WSASocket API"

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpc++visual-studiocom
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bkelly13
    wrote on last edited by
    #1

    Windows 7, Visual Studio 2012, C++ The Microsoft Web page discussing "

    Quote:

    Socket overlapped I/O versus blocking/nonblocking mode

    found here: http://support.microsoft.com/kb/181611[^] states:

    Quote:

    To create a socket with the overlapped I/O attribute, you can either use the socket API or the WSASocket API with the WSA_FLAG_OVERLAPPED flag set.

    (I added the bolds in the above quote.) What is the difference between socketAPI and WSASocket API? Please show a code fragment that creates a socket with socket API and another that creates it with WSASocket API.

    Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

    Richard Andrew x64R L A 3 Replies Last reply
    0
    • B bkelly13

      Windows 7, Visual Studio 2012, C++ The Microsoft Web page discussing "

      Quote:

      Socket overlapped I/O versus blocking/nonblocking mode

      found here: http://support.microsoft.com/kb/181611[^] states:

      Quote:

      To create a socket with the overlapped I/O attribute, you can either use the socket API or the WSASocket API with the WSA_FLAG_OVERLAPPED flag set.

      (I added the bolds in the above quote.) What is the difference between socketAPI and WSASocket API? Please show a code fragment that creates a socket with socket API and another that creates it with WSASocket API.

      Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      Those are the names of the functions:

      SOCKET WSAAPI socket(
      _In_ int af,
      _In_ int type,
      _In_ int protocol
      );

      SOCKET WSASocket(
      _In_ int af,
      _In_ int type,
      _In_ int protocol,
      _In_ LPWSAPROTOCOL_INFO lpProtocolInfo,
      _In_ GROUP g,
      _In_ DWORD dwFlags
      );

      The main difference is that socket is a function in the C runtime, and WSASocket is a Windows API.

      The difficult we do right away... ...the impossible takes slightly longer.

      1 Reply Last reply
      0
      • B bkelly13

        Windows 7, Visual Studio 2012, C++ The Microsoft Web page discussing "

        Quote:

        Socket overlapped I/O versus blocking/nonblocking mode

        found here: http://support.microsoft.com/kb/181611[^] states:

        Quote:

        To create a socket with the overlapped I/O attribute, you can either use the socket API or the WSASocket API with the WSA_FLAG_OVERLAPPED flag set.

        (I added the bolds in the above quote.) What is the difference between socketAPI and WSASocket API? Please show a code fragment that creates a socket with socket API and another that creates it with WSASocket API.

        Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        The functions such as socket[^] are the old style socketAPI group, based on BSD sockets from the early days of UNIX. The WSAxxx functions are the later Microsoft adaptation.

        B 1 Reply Last reply
        0
        • L Lost User

          The functions such as socket[^] are the old style socketAPI group, based on BSD sockets from the early days of UNIX. The WSAxxx functions are the later Microsoft adaptation.

          B Offline
          B Offline
          bkelly13
          wrote on last edited by
          #4

          Is there a difference in speed? Edit: My email shows another response that says

          Quote:

          The main difference is that socket is a function in the C runtime, and WSASocket is a Windows API.

          That response does not show up when I log in here. So can I presume that the WSAxxx versions are faster since they bypass the C runtime, which are, presumably, wrappers that then call the API internally?

          Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

          L Richard Andrew x64R 2 Replies Last reply
          0
          • B bkelly13

            Is there a difference in speed? Edit: My email shows another response that says

            Quote:

            The main difference is that socket is a function in the C runtime, and WSASocket is a Windows API.

            That response does not show up when I log in here. So can I presume that the WSAxxx versions are faster since they bypass the C runtime, which are, presumably, wrappers that then call the API internally?

            Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            bkelly13 wrote:

            can I presume that the WSAxxx versions are faster since they bypass the C runtime

            No, you cannot presume anything. It is quite possible (but I don't know) that WSA is built on top of sockets rather than being a complete re-implementation.

            1 Reply Last reply
            0
            • B bkelly13

              Is there a difference in speed? Edit: My email shows another response that says

              Quote:

              The main difference is that socket is a function in the C runtime, and WSASocket is a Windows API.

              That response does not show up when I log in here. So can I presume that the WSAxxx versions are faster since they bypass the C runtime, which are, presumably, wrappers that then call the API internally?

              Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

              Richard Andrew x64R Offline
              Richard Andrew x64R Offline
              Richard Andrew x64
              wrote on last edited by
              #6

              That response was from me. I deleted it because it was wrong. The socket function is not in the C runtime. I'm sorry to have misled you.

              The difficult we do right away... ...the impossible takes slightly longer.

              1 Reply Last reply
              0
              • B bkelly13

                Windows 7, Visual Studio 2012, C++ The Microsoft Web page discussing "

                Quote:

                Socket overlapped I/O versus blocking/nonblocking mode

                found here: http://support.microsoft.com/kb/181611[^] states:

                Quote:

                To create a socket with the overlapped I/O attribute, you can either use the socket API or the WSASocket API with the WSA_FLAG_OVERLAPPED flag set.

                (I added the bolds in the above quote.) What is the difference between socketAPI and WSASocket API? Please show a code fragment that creates a socket with socket API and another that creates it with WSASocket API.

                Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

                A Offline
                A Offline
                AmitCohen222
                wrote on last edited by
                #7

                Hi bkelly13 ! The "WSASocket API" are Microsoft-specific new functions for handling sockets in Windows. If your code is to run on Windows machines only go with this new API since it provides more flexibility and some functionality benefits when working with types of sockets other than blocking. Here are some qoutes from the Remarks paragraph in the MSDN regarding WSARecv:

                Quote:

                The WSARecv function provides some additional features compared with the standard recv function in three important areas: •It can be used in conjunction with overlapped sockets to perform overlapped recv operations. •It allows multiple receive buffers to be specified making it applicable to the scatter/gather type of I/O. •The lpFlags parameter is used both on input and returned on output, allowing applications to sense the output state of the MSG_PARTIAL flag bit. However, the MSG_PARTIAL flag bit is not supported by all protocols.

                Same goes for WSASend:

                Quote:

                The WSASend function provides functionality over and above the standard send function in two important areas: •It can be used in conjunction with overlapped sockets to perform overlapped send operations. •It allows multiple send buffers to be specified making it applicable to the scatter/gather type of I/O.

                You can also find code examples for working with these API in there. I have created and worked with sockets using this API (Blocking mode and event-based Overlapped mode) and overall it seems to work fine. If relevant, I can send you the code. :cool: Bye, Amit C.

                B 1 Reply Last reply
                0
                • A AmitCohen222

                  Hi bkelly13 ! The "WSASocket API" are Microsoft-specific new functions for handling sockets in Windows. If your code is to run on Windows machines only go with this new API since it provides more flexibility and some functionality benefits when working with types of sockets other than blocking. Here are some qoutes from the Remarks paragraph in the MSDN regarding WSARecv:

                  Quote:

                  The WSARecv function provides some additional features compared with the standard recv function in three important areas: •It can be used in conjunction with overlapped sockets to perform overlapped recv operations. •It allows multiple receive buffers to be specified making it applicable to the scatter/gather type of I/O. •The lpFlags parameter is used both on input and returned on output, allowing applications to sense the output state of the MSG_PARTIAL flag bit. However, the MSG_PARTIAL flag bit is not supported by all protocols.

                  Same goes for WSASend:

                  Quote:

                  The WSASend function provides functionality over and above the standard send function in two important areas: •It can be used in conjunction with overlapped sockets to perform overlapped send operations. •It allows multiple send buffers to be specified making it applicable to the scatter/gather type of I/O.

                  You can also find code examples for working with these API in there. I have created and worked with sockets using this API (Blocking mode and event-based Overlapped mode) and overall it seems to work fine. If relevant, I can send you the code. :cool: Bye, Amit C.

                  B Offline
                  B Offline
                  bkelly13
                  wrote on last edited by
                  #8

                  I understand and am going with the WSA series. I am putting significant effort into this project. If you have code you don't mind sending, I will look at it. I am declaring my code as open source and will post it. Please send to user name "online" with that symbol followed by my domain bkelly then further followed by dot "ws", yes, its just that simple. Thank you for the time you spent on your reply.

                  Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups