How to set the "sock_accept" to the blocking mode?
How to set the "sock_accept" to the blocking mode?
- Subject: How to set the "sock_accept" to the blocking mode?
- From: "peiyuan" <email@hidden>
- Date: Thu, 23 Aug 2007 16:36:31 +0800
Hi,
I was trying to set the sock_accept to blocking mode. However, no matter how
I set the blocking mode, it still returns EWOULDBLOCK. My code is like
below:
set_nonblocking(so, 0);
err = sock_accept(so, (struct sockaddr *)&from, alen, MSG_DONTWAIT,
(sock_upcall)&sock_accept_callback, (void*)cookie, &new_so);
------------------------------------------------
errno_t set_nonblocking(socket_t so, int value)
{
errno_t err;
int val = value;
if(value != 0 && value != 1) return EINVAL;
err = sock_ioctl(so, FIONBIO, &val);
return err;
}
-------------------------------------------------
the err return EWOULDBLOCK. I have check out the kpi_socket.h. It says that
the flags in sock_accept could only use MSG_DONTWAIT or MSG_USEUPCALL. If I
set to MSG_DONTWAIT and there is no connections, it would return
EWOULDBLOCK. I think this is why I got EWOULDBLOCK.
But isn't this behavior the non-blocking behavior? What am I doing wrong? I
just want to set it to the blocking mode.
Please help me. Thank you.
Pei-Yuan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden