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