Re: bind, connect, etc. and nonblocking mode
Re: bind, connect, etc. and nonblocking mode
- Subject: Re: bind, connect, etc. and nonblocking mode
- From: Quinn <email@hidden>
- Date: Thu, 28 Mar 2002 10:18:00 +0000
At 14:13 -0700 25/3/02, Zack Morris wrote:
I am just wondering about edge cases for functions other than sending
and receiving. For instance, say I bind an endpoint/socket. For UDP, I
will get a T_BINDCOMPLETE in the notifier, and the routine should return
kOTNoError. What do I do in the meantime? Do I have the socket's bind()
routine return 0? The problem is that there is a small chance that it will
still be unbound when I try to send, so it might give me a TOUTSTATE error
if I try to call sendto() (OTSndUData() internally). I think there is a way
to set a flag from my notifier so that my select() will notice it and mark
that socket as useable. Otherwise, can I look at the state somehow and have
sendto() return an error if the endpoint is not bound yet?
In this case I would do the OTBind in sync/blocking mode. That way
you won't return until the bind is complete (which is what your
'sockets' clients are expecting). Once the bind is complete you
should then switch to async/blocking mode so that you can get your
timestamps on receives.
I have a host of similar edge cases for connect, accept, etc. I have
read the man pages for them, but they are just not clear about exactly what
results are returned for nonblocking sockets, and how to find out if an
action has completed.
Welcome to sockets. There is no formal spec, the right thing to do
is not always obvious, and there's a lot of variation between
platforms. Stevens' "UNIX Network Programming" covers a lot of the
edge cases. If you look up "non-blocking" in the index you'll get
some useful info.
S+E
--
Quinn "The Eskimo!" <
http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications, Hardware
_______________________________________________
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.