• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CFSocketSetAddress failing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CFSocketSetAddress failing


  • Subject: CFSocketSetAddress failing
  • From: Tomas Franzén <email@hidden>
  • Date: Mon, 26 Sep 2005 00:54:22 +0200

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,

Tomas Franzén

Lighthead Software

http://www.lightheadsw.com/

 _______________________________________________
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

  • Prev by Date: Re: choosing a network port
  • Next by Date: Re: CFSocketSetAddress failing
  • Previous by thread: Re: choosing a network port
  • Next by thread: Re: CFSocketSetAddress failing
  • Index(es):
    • Date
    • Thread