Re: Socket "bind" isn't working for me
Re: Socket "bind" isn't working for me
- Subject: Re: Socket "bind" isn't working for me
- From: John Draper <email@hidden>
- Date: Sat, 23 Apr 2005 14:51:44 -0700
Hi again,
Thanx to those that responded to my earlier message on my "bind"
problem, and I'm
on here yet again to give out additional information I found...
I needed to #import errno.h to get this to work. But it turned out that
the EDCommon framework had it so well hidden it took a long time for me
to figure that out.
I was also given the reference to a book called "UNIX Network
programming - Vol 1"
and after visiting Frys, Borders, Barns and Noble, and about 5 - 7
local used book shops
all over Burbank, Ca, I couldn't obtain a copy, and was told it was
out of print.
But someone gave me a reference to Jeez and am reading this now.
http://www.ecst.csuchico.edu/~beej/guide/net/html/theory.html
if anyone is interested...
The error number is #22... according to the errno.h it says "Invalid
Argument", but the
"man 2 bind" says...
[EINVAL] The socket is already bound to an address.
Ok, but whats wrong with that? In the Windows (which is remarkebly
similar to UNIX
sockets), their bind can bind to more then one address...
Another thing I didn't mention in my earlier posting was that I was also
setting my
SocketOpt to SO_REUSEADDR and SO_REUSEPORT respectively. In fact,
the EDCommon framework indicates that... in these two method calls in
EDIPSocket.m
#ifdef __APPLE__
- (void)setAllowsPortReuse:(BOOL)flag
{
[self setSocketOption:SO_REUSEPORT level:SOL_SOCKET value:flag];
}
#endif
- (void)setAllowsAddressReuse:(BOOL)flag
{
[self setSocketOption:SO_REUSEADDR level:SOL_SOCKET value:flag];
}
Which is described as:
Controls how quickly an address/port combination can be re-used.
With this option set a socket can be connected to a port that
is still in !{TIME_WAIT} state which is useful if your server
has been shut down, and then restarted right away while sockets
are still active on its port. You should be aware that if any
unexpected data comes in, it may confuse your server, but while
this is possible, it is not likely. This corresponds to
!{SO_REUSEADDR}.
So why am I getting this error "The socket is already bound to an address"?
and how can I selectively send data to two remote machines? Not at the
same time of course, but selectively, using "sendto" - which ALWAYS
returns a -1 instead of the actual number of bytes it would have sent?
I tried to "cash in" on an instance of support from Apple, but they don't
offer assistance in anything but Apple written code.
I even went to the Apple Booth at NAB in Vegas and found an Apple engineer
but he said that it is Apple's policy not to offer "Unauthorized support"...
Is that the reason why Apple isn't making much of a presence on these lists?
or is this person just politely trying to tell me to "shove off".
John
_______________________________________________
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