• 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
Re: Socket "bind" isn't working for me
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Socket "bind" isn't working for me


  • Subject: Re: Socket "bind" isn't working for me
  • From: Justin Walker <email@hidden>
  • Date: Sat, 23 Apr 2005 15:34:02 -0700


On Apr 23, 2005, at 14:51, John Draper wrote:

[snip]
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...

Nope; AFAIK, you can't bind to more than one address. See below.

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
[snip]
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?

You really need to get this straight: - bind assigns values to the local endpoint; if you don't do it, the kernel will (assuming you are the client), at the point you start using the socket. This has zilch to do with the remote endpoint. - sendto takes arguments that specify the remote address; that's how you send to multiple destinations via a datagram socket

The bind() error is the fundamental issue for you. It turns out that the man page is not completely correct. The call also returns EINVAL only (AFAICT) if the socket descriptor you pass in isn't really a socket descriptor, or if there is another problem with the sockaddr structure you pass in.

Also, two notes on your code:
  - although on PowerPC, network and host byte order are the same,
    your code should set both the port and the address to network
    byte order;
  - I think the length value has to be set in the sockaddr
The latter could cause the bind() call to fail.

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?

Apple is a presence on all of these lists. However, you have to bear in mind that (a) the lists are here for developers to interact; (b) those Apple employees who contribute do so essentially as individuals; and (c) these lists are not "official" channels into or out of Apple.


Regards,

Justin

--
Justin C. Walker, Curmudgeon-At-Large
Institute for General Semantics
--------
Men are from Earth.
Women are from Earth.
   Deal with it.
--------

_______________________________________________
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


  • Follow-Ups:
    • Re: Socket "bind" isn't working for me
      • From: Cameron Kerr <email@hidden>
    • Re: Socket "bind" isn't working for me
      • From: Justin Walker <email@hidden>
References: 
 >Re: Socket "bind" isn't working for me (From: John Draper <email@hidden>)

  • Prev by Date: Re: Socket "bind" isn't working for me
  • Next by Date: Re(2): Socket "bind" isn't working for me
  • Previous by thread: Re: Socket "bind" isn't working for me
  • Next by thread: Re: Socket "bind" isn't working for me
  • Index(es):
    • Date
    • Thread