-
March 11th, 2011, 12:36 PM
#1
select returns 10038 on 64 bit system
The following code has been running for several years without problems on 32 bit systems. We are now attempting to build the code for a 64 bit Windows 7 system. The select statement is returning a 10038 error. The socket was ok in the "bind" and "listen" function calls. Perhaps the structure being built by FD_SET is aligned improperly? Any ideas?
int rc = 0, temprc = 0;
SOCKET AcceptSocket = 0, objListenSocket = 0;
struct sockaddr_in socketinfo, acceptinfo;
int iLength;
struct timeval stTimeout;
fd_set structReadFDS;
char cLogBuffer[150];
// Create the listening socket
objListenSocket = socket (AF_INET, SOCK_STREAM, 0);
if (objListenSocket == INVALID_SOCKET)
{
rc = XSRV_COULDNT_CREATE_SOCKET;
temprc = WSAGetLastError();
goto exit1;
}
// Bind the socket
// Port number must be in Network byte order (big endian)
memset (&socketinfo, '\0', sizeof(socketinfo));
socketinfo.sin_family = AF_INET;
socketinfo.sin_port = htons(47809);
socketinfo.sin_addr.s_addr = INADDR_ANY;
rc = bind(objListenSocket, (struct sockaddr *)&socketinfo, sizeof(socketinfo));
if (rc == SOCKET_ERROR)
{
temprc = WSAGetLastError();
rc = XSRV_COULDNT_BIND_SOCKET;
goto exit1;
}
// Listen on the socket for a connection, backlog = 5 deep (the max)
rc = listen(objListenSocket, SOMAXCONN);
if (rc == SOCKET_ERROR)
{
temprc = WSAGetLastError();
rc = XSRV_COULDNT_LISTEN_ON_SOCKET;
goto exit1;
}
// Use select to determine if there is any data on the listening
// socket. If not, don't try to accept. This keeps the accept from
// blocking.
// Initialize the select structure with listening socket.
FD_ZERO(&structReadFDS);
FD_SET(objListenSocket, &structReadFDS);
// Select timesout in 1/2 a second
temprc = select(NULL, &structReadFDS, NULL, NULL, &stTimeout);
// If error
if (temprc == SOCKET_ERROR)
{
temprc = WSAGetLastError();
rc = XSRV_COULDNT_SELECT;
goto exit2;
}
-
March 11th, 2011, 01:11 PM
#2
Re: select returns 10038 on 64 bit system
as far as I can see, stTimeout is not initialized. May this cause a problem? The rest of the code looks ok to me.
-
March 14th, 2011, 08:58 AM
#3
Re: select returns 10038 on 64 bit system
Sorry, I left out the initialization of stTimeout when I copied the code snippet. It is being initialized. The select simply fails to work on the 64 bit system.
-
March 18th, 2011, 06:20 AM
#4
Re: select returns 10038 on 64 bit system
can you see that the socket is created correctly. Try using netstat or TcpView to see that the socket is correctly opened. I understand that bind() and listen() succeed, but I would make sure I can "see" the socket.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|