Re: macnetworkprog digest, Vol 3 #585 - 5 msgs
Re: macnetworkprog digest, Vol 3 #585 - 5 msgs
- Subject: Re: macnetworkprog digest, Vol 3 #585 - 5 msgs
- From: Martin Bestmann <email@hidden>
- Date: Wed, 19 Nov 2003 08:48:21 +0100
I've figured out what the problem is.
I created the socket with CFSocketCreateWithSocketSignature.
After that I called
setsockopt(CFSocketGetNative(xIPv4Socket),SOL_SOCKET,SO_REUSEADDR,&yes,s
izeof(yes));
This call succeeds even so it has no effect on the socket.
It turns out if I use CFSocketCreate then call setsockopt and then call
CFSocketSetAddress everything works.
So the looks like that I have to set the SO_REUSEADDR before the socket
goes into listing mode.
Is this a bug or is this the way it is. If this is a bug I'll file a
bug report other wise I think setsockopt should not succeed if the
socket is already listing.
Martin
On 19.11.2003, at 07:01, email@hidden wrote:
I did use the echo sample as base for checking how this do work.
According to the comment in Server.c before the setsockopt it says
// In order to accomadate stopping and starting the process without
closing the socket,
// set the addr for resuse on the native socket. This is not
required if the port is
// being supplied by the OS opposed to being specified by the user.
Which would mean the socket will not be release when the stream goes
away which is not what I want. In any case I did try this and it
doesn't work.
After calling
CFStreamCreatePairWithSocket(kCFAllocatorDefault,inSocket,&xReadStream,
&
xWriteStream);
With inSocket being the PlatformSocketHandle from the callback I do
call
// Give up ownership of the native socket.
CFReadStreamSetProperty(xReadStream,kCFStreamPropertyShouldCloseNativeS
o
cket,kCFBooleanTrue);
Which should do what I want.
Any other ideas. BTW everything works perfect if the client is closing
the connection to the server instead of the server closing the
connection.
------------------------------------------------------------------------
-----------------------
Martin Bestmann Netopia
Development GmbH
Phone: +49-9134-9942-0 Weingasse 26
Fax: +49-9134-997911 91077 Neunkirchen am
Brand
e-mail:email@hidden Germany
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.