Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows sockets 2 #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

DimitriPapadopoulos
Copy link

Make sure the code conforms to the Windows Socket 2 documentation.

@DimitriPapadopoulos
Copy link
Author

DimitriPapadopoulos commented Dec 28, 2021

https://docs.microsoft.com/windows/win32/api/winsock2/nf-winsock2-accept

SOCKET WSAAPI accept(
  [in]      SOCKET   s,
  [out]     sockaddr *addr,
  [in, out] int      *addrlen
);

https://docs.microsoft.com/windows/win32/api/winsock/nf-winsock-bind

int bind(
  [in] SOCKET         s,
       const sockaddr *addr,
  [in] int            namelen
);

https://docs.microsoft.com/windows/win32/api/winsock2/nf-winsock2-connect

int WSAAPI connect(
  [in] SOCKET         s,
  [in] const sockaddr *name,
  [in] int            namelen
);

https://docs.microsoft.com/windows/win32/api/winsock/nf-winsock-getsockname

int getsockname(
  [in]      SOCKET   s,
  [out]     sockaddr *name,
  [in, out] int      *namelen
);

https://docs.microsoft.com/windows/win32/api/winsock/nf-winsock-setsockopt

int setsockopt(
  [in] SOCKET     s,
  [in] int        level,
  [in] int        optname,
  [in] const char *optval,
  [in] int        optlen
);

https://docs.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsasocketa
https://docs.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsasocketw

SOCKET WSAAPI WSASocketA(
  [in] int                 af,
  [in] int                 type,
  [in] int                 protocol,
  [in] LPWSAPROTOCOL_INFOA lpProtocolInfo,
  [in] GROUP               g,
  [in] DWORD               dwFlags
);

SOCKET WSAAPI WSASocketW(
  [in] int                 af,
  [in] int                 type,
  [in] int                 protocol,
  [in] LPWSAPROTOCOL_INFOW lpProtocolInfo,
  [in] GROUP               g,
  [in] DWORD               dwFlags
);

@DimitriPapadopoulos DimitriPapadopoulos force-pushed the windows_sockets_2 branch 5 times, most recently from 9fae0da to 2695757 Compare December 28, 2021 19:21
@DimitriPapadopoulos
Copy link
Author

The actual optval argument type is DWORD (boolean) for the SOL_SOCKET
socket option SO_REUSEADDR:
  https://docs.microsoft.com/windows/win32/winsock/sol-socket-socket-options

The type of the optlen argument of setsockopt() is "int":
  https://docs.microsoft.com/windows/win32/api/winsock/nf-winsock-setsockopt#syntax

The type of the namelen argument of getsockname() is "int *":
  https://docs.microsoft.com/windows/win32/api/winsock/nf-winsock-getsockname#syntax

After these changes, socklen_t is not used anymore. Therefore we can
revert from <w2stcpip.h> to <winsock2.h>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant