| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
| Hi, I have a problem with my code which uses the CFSocket APIs. • I listen on a port (with CFSocketSetAddress) and connect with a client. The client closes its connection and I close the listening socket. I can listen on the same port again - no problem in this case. • I listen on a port and connect with a client and let my code disconnect the client. Then I close the listening socket. But when I try to listen on the same port again with a new socket, CFSocketSetAddress fails with kCFSocketError (wow, what a descriptive error :-). After about a minute, I can listen on the port again after it fails. There seems to be a timeout of some kind. Even if I quit my program, I can't listen on the port after relaunching. I still have to wait for something to time out! I have a few questions that I figure may clear up my mind on this issue. 1. What's the proper way for my program to close the connection to the client? Maybe I'm doing something wrong here. I call CFSocketInvalidate. I have not set any special flags for the socket, so the kCFSocketCloseOnInvalidate stuff shouldn't be the problem. 2. What's the proper way to stop a socket from listening? I use CFSocketInvalidate here too. I also loop through a saved list of all connected clients and close their connections first. 3. Any idea of what that timeout may be for? That could bring some hints to why I have this problem. I have also tried to get the native socket handle and use close() on it (for both server and client), but that doesn't improve things. Grateful for any help, |
_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/macnetworkprog/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.