CFSocketIsValid(), select() and blocking
CFSocketIsValid(), select() and blocking
- Subject: CFSocketIsValid(), select() and blocking
- From: Liwei <email@hidden>
- Date: Sat, 11 Oct 2008 02:41:59 +0800
[Yay, thank to Quinn's helpful insight, I've got TCP socket listening working!]
Now I've got another five questions, heh.
First, I would like to be able to tell if a socket (TCP or UDP) is connected.
I know UDP is connectionless, so I'll just need to know if it is
writable now or maybe in the future (i.e. the socket is proper, just
that its currently busy sending/receiving data). For TCP, I need to
know if a client is connected to it, without manually updating flags
when a client connects and disconnects*.
I see two possible functions I can use (suggestions for other better
functions are welcome), CFSocketIsValid() and select().
I know that select() can tell me whether I can read or write at the
moment, but I'm not sure if it can tell if a socket is disconnected or
just busy sending/receiving data (do I infer that by looking at
whether it has any exceptions?)
Same for CFSocketIsValid(), does it return false when the socket is
valid (?) but currently busy sending/receiving data?
Second, how do I make sure that only one client can be connected at a
time? Do I just disable the kCFSocketAcceptCallBack after the first
client connects?
Third, is it safe to not close sockets before I terminate the application?
Fourth, how does SO_REUSEPORT affect my sockets?
* Fifth, how am I notified of a client disconnecting?
I'm learning everything as I go along, so sorry for the large amount
of questions!
_______________________________________________
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