Re: BSD socket accept() fd leak on iphone OS
Re: BSD socket accept() fd leak on iphone OS
- Subject: Re: BSD socket accept() fd leak on iphone OS
- From: Jay Bone <email@hidden>
- Date: Fri, 25 Sep 2009 15:08:57 -0700
On Fri, Sep 25, 2009 at 1:57 PM, Terry Simons
<email@hidden> wrote:
Did you remove your close() calls in favor of shutdown, or are you
still closing the socket? If you aren't closing the socket, then you
are probably leaking descriptors which might explain why they aren't
getting reused?
Just a guess.
Also, as I understand it you should shutdown() the socket and then
close() it (much of the code on the internet does not do this, but
IIRC, according to the Stevens book this is the proper way), but you
should only shutdown/close when you are done reading/writing the
socket.
I believe that's what I am doing. Is it not?
Anyway I have this running in the simulator now and I think I've found my problem. Though this still confuses me a bit.
I was using my own debug class to log to the device's file system rather than using NSLog.
I was using NSFileHandle to open and write to a file but I wasn't calling NSFileHandle 's -closeFile. (Calling this fixes my problem.)
Presumably this was consuming the fd's so accept() had none available to return to me.
What confuses me is that I've used this same debug class in several other projects and have never had a problem. I'm sure it's logged more than 256 lines of debug messages. Though these other projects may have been less fd intensive. Still I'd think this debug class bug would have showed itself when logging ~256 lines of debug messages. Odd. Maybe someone can explain that, but it's probably off topic.
So sorry for a bit of a red herring here and thanks everyone for the replies.
-J
_______________________________________________
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