Select problem
Select problem
- Subject: Select problem
- From: Mike Cohen <email@hidden>
- Date: Tue, 6 Apr 2004 16:28:24 -0400
Hi,
I'm rewriting some old code which used OT with an asynchronous notifier
to use sockets with select. I have a thread running the following code,
which as far as I can tell is a pretty standard select loop. It works
correctly the first time - select returns when data is ready and I read
the 149 byte packet correctly. However, after that select returns
immediately and read returns 0 bytes and it continues like that until I
stop it.
Any idea what could be wrong?
#define RB_SIZE 2048
char recvbuff[RB_SIZE];
static void BSDConnection::SelectLoop (void *info)
{
int sock;
size_t rcount;
fd_set readfds;
FD_ZERO(&readfds);
for (;;)
{
FD_SET(sock, &readfds);
if(select(sock+1, &readfds, NULL, NULL, NULL) > 0)
{
if (FD_ISSET(sock, &readfds))
{
rcount = read(sock,recvbuff,RB_SIZE);
if (rcount > 0)
{
ProcessData(recvbuff, rcount);
}
}
}
}
}
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.