I have a server, which does create an NSConnection on some NSSocketPort and publishes this fact via Bonjour. A client opens a connection, sends some messages via Distributed Objects, and closes it again.
This implies opening and closing a few file descriptors on sockets.

Works fine. Usually.

But sometimes some of these socket file descriptors get NOT closed, so they accumulate slowly and when the limit set in limit() is reached, the client blocks forever.

So there are a two bugs (hopefully not mine):
1. these file descriptors should get closed, and
2. the client should get an error message or an exception instead just blocking forever. But as this is 10.4.11 there is no chance that these bugs (if not indeed mine) will ever get fixed.

Questions:
What stupidity on my side could be the reason of the sockets not being closed? If someone is interested, I can show the details of the creation of the NSConnection.

When should these sockets get closed? I have (using lsof) observed that these sometimes disappear immediately after the conversation, sometimes linger on for some time - to be removed eventually; and sometimes linger on indefinitely.

How does the server notice when the client does:
        [connectionToServer invalidate]; [connectionToServer release]; ?
I assume that the sockets used for the conversation should be closed at this point. Correct?

My current workaround:
for i in gettablesize() do
        fstat(i);
        if not S_IFSOCK then continue;
        getsockname()
        if port ≠ MyPort continue;
        count++
endfor
if count > 5 then close(oldest file descriptor)

Not very elegant; not even sure it will work - this bug is not really reproducible - only time will tell.
But maybe someone has a better idea.


Kind regards,

Gerriet.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to