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. AcceptEx parameter type question

AcceptEx parameter type question

Scheduled Pinned Locked Moved C / C++ / MFC
delphiquestion
3 Posts 3 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.
  • F Offline
    F Offline
    followait
    wrote on last edited by
    #1

    BOOL
    PASCAL FAR
    AcceptEx (
    IN SOCKET sListenSocket,
    IN SOCKET sAcceptSocket,
    IN PVOID lpOutputBuffer,
    IN DWORD dwReceiveDataLength,
    IN DWORD dwLocalAddressLength,
    IN DWORD dwRemoteAddressLength,
    OUT LPDWORD lpdwBytesReceived,
    IN LPOVERLAPPED lpOverlapped
    );

    For the 2nd parameter, why not use IN SOCKET &sAcceptSocket instead.

    C R 2 Replies Last reply
    0
    • F followait

      BOOL
      PASCAL FAR
      AcceptEx (
      IN SOCKET sListenSocket,
      IN SOCKET sAcceptSocket,
      IN PVOID lpOutputBuffer,
      IN DWORD dwReceiveDataLength,
      IN DWORD dwLocalAddressLength,
      IN DWORD dwRemoteAddressLength,
      OUT LPDWORD lpdwBytesReceived,
      IN LPOVERLAPPED lpOverlapped
      );

      For the 2nd parameter, why not use IN SOCKET &sAcceptSocket instead.

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      followait wrote:

      For the 2nd parameter, why not use IN SOCKET &sAcceptSocket instead.

      Because if you look at what a SOCKET is, you'll see that it is just an UINT_PTR. In fact a SOCKET is just a handle to a win32 internal object. So, yjust passing this handle is enough, you don't need to pass the handle by reference.

      Cédric Moonen Software developer
      Charting control [v1.5] OpenGL game tutorial in C++

      1 Reply Last reply
      0
      • F followait

        BOOL
        PASCAL FAR
        AcceptEx (
        IN SOCKET sListenSocket,
        IN SOCKET sAcceptSocket,
        IN PVOID lpOutputBuffer,
        IN DWORD dwReceiveDataLength,
        IN DWORD dwLocalAddressLength,
        IN DWORD dwRemoteAddressLength,
        OUT LPDWORD lpdwBytesReceived,
        IN LPOVERLAPPED lpOverlapped
        );

        For the 2nd parameter, why not use IN SOCKET &sAcceptSocket instead.

        R Offline
        R Offline
        Rajkumar R
        wrote on last edited by
        #3

        because the second parameter is not a return value. In AcceptEx,You need to have accept socket opened already unlike the accept API in which the socket is returned. from msdn,

        Another key difference between the AcceptEx function and the accept function is that AcceptEx requires the caller to already have two sockets:

        One that specifies the socket on which to listen.
        One that specifies the socket on which to accept the connection.

        The sAcceptSocket parameter must be an open socket that is neither bound nor connected.

        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