"Kai Blin" kai.blin@gmail.com wrote:
+static void test_extendedSocketOptions() +{
- WSADATA wsa;
- SOCKET sock;
- struct sockaddr_in sa;
- int sa_len = sizeof(struct sockaddr_in);
- ULONG optval, optlen = sizeof(ULONG);
Why to use ULONG if what you later cast it to is 'int *', and according to the docs (and your implementation) SO_MAX_MSG_SIZE expects sizeof(int) for the optval?
...
- if(bind(sock, (struct sockaddr *) &sa, (int)sa_len) < 0){
There is not need for a cast, sa_len has the type 'int'.
trace("Failed to bind socket: 0x%08x\n", WSAGetLastError());
closesocket(sock);
WSACleanup();
exit(1);
This kills the whole process instead of terminating gracefully just this particular test.
- }
- ret = getsockopt(sock, SOL_SOCKET, SO_MAX_MSG_SIZE, (char *)&optval, (int *)&optlen);
On Tuesday 28 November 2006 17:05, Dmitry Timoshkov wrote:
"Kai Blin" kai.blin@gmail.com wrote:
+static void test_extendedSocketOptions() +{
- WSADATA wsa;
- SOCKET sock;
- struct sockaddr_in sa;
- int sa_len = sizeof(struct sockaddr_in);
- ULONG optval, optlen = sizeof(ULONG);
Why to use ULONG if what you later cast it to is 'int *', and according to the docs (and your implementation) SO_MAX_MSG_SIZE expects sizeof(int) for the optval?
Because another part of the docs says SO_MAX_MSG_SIZE expects ULONG.
...
- if(bind(sock, (struct sockaddr *) &sa, (int)sa_len) < 0){
There is not need for a cast, sa_len has the type 'int'.
Whoops, copy&paste error from my linux test program, where sa_len was a size_t.
trace("Failed to bind socket: 0x%08x\n", WSAGetLastError());
closesocket(sock);
WSACleanup();
exit(1);
This kills the whole process instead of terminating gracefully just this particular test.
Yeah, forgot to convert that from the standalone test I wrote first. Reading all the code in socket.c must have turned my brain all mushy.
Thanks for catching those. I'll fix it and resubmit. Kai