• 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: kEADDRINUSEErr and OTConnect() confusion...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: kEADDRINUSEErr and OTConnect() confusion...


  • Subject: Re: kEADDRINUSEErr and OTConnect() confusion...
  • From: Alin Pilkington <email@hidden>
  • Date: Mon, 10 Nov 2003 12:58:03 -0800

Hi Quinn,

Thanks for the response...I've made comments and answered your questions below...
On Monday, November 10, 2003, at 07:59 AM, Quinn wrote:

At 14:00 -0800 1/11/03, Alin Pilkington wrote:
1) I don't understand this situation at all since in the OT docs, it says that if the endpoints are async (and using a notifier to handle events), the call to OTConnect() should return a KOTNoDataErr and then upon the T_CONNECT event, the result of the previously issued OTConnect() can be determined. Why do I get the kEADDRINUSEErr right away? I don't think it behaved this way on OS 9...

When doing an async operation, you must be prepared to handle the error coming back immediately or, if the immediate result indicates that the async operation is proceeding asynchronously, from the notifier. The implementation is free to choose which errors are returned via which mechanism on a call-by-call basis.

For example, traditional Mac OS would always return certain errors (typically parameter errors, like kEBADFErr) immediately, but the error kEADDRINUSEErr would always come back via the notifier. OTOH, the Mac OS X OT framework always completes binds immediately (because the underlying API, BSD sockets, has no asynchronous bind), so now kEADDRINUSEErr is an immediate error.

Ok...this must be the reason that I see this now but never did on OS 9 ***BUT*** I don't see this error (kEADDRINUSEErr ) on the OTBind() call, I see it on the OTConnect() call.


2) I'm in need of an education here...which address is it complaining about as being in use? It can't be the active endpoint since it is already bound to a port (I used kOTAnyAddress) and got back no errors in the T_BINDCOMPLETE event. Is it the listener port on the remote computer that it is complaining about as being in use?? That is why I tried to increase the qLen of the listener port thinking that the queue might be full...

The way I read your email, it seems that you're calling OTConnect in response to a T_BINDCOMPLETE message for the listening endpoint. That's very unusual. Did I get this right? Who are you trying to connect to?


To give you a context, I am using code that was shamelessly pilfered (and without any guilt whatsoever) from your OTVirtualServer/OTVirtualClient samples. I am trying to connect to a specific port on a remote Mac (which is also running our application).

I should add that I have a queue of endpoints already opened and already bound to local wildcard ports from which I get an endpoint and issue an OTConnect to the remote mac. This is where the error sometimes occurs. This is a little different than what you did in your OTVirtualClient code...in there, you had a queue of endpoints that were in an unbound state. I changed this just recently to try and see if this fixed (or changed the behavior of my OTConnect problem...it didn't).

Now, when I say my endpoints are bound to wildcard ports, I mean I used kOTAnyInetAddress for the port parameter to OTInitInetAddress() and I explicitly specify the IP address of my local Mac for the host parameter. The resulting initialized InetAddress structure is then referenced from a TBind structure which is passed in to OTBind(). In other words, my call to OTBind() looks like this:

OTBind(ep, &sendBindreq, &actBindInfo)

whereas in your example down below, you suggested using

OTBind(ep, NULL, NULL);

Is there any difference between the two given my use of kOTAnyInetAddress in initializing the port for InetAddress structure?

Regardless, there are two likely causes of the error.

1. IP_REUSEADDR -- Make sure you set IP_REUSEADDR on your listening endpoint. See DTS Q&A NW 17 "Unbinding from a TCP Port" for details.

<http://developer.apple.com/qa/nw/nw17.html>

Ya...this I do for the listener endpoint, in fact, all of the endpoints I create have this option set. Maybe I should not set this option for the local ports other than the listener?


2. Bind for connect -- When binding the client endpoint (that is, the one you're going to pass to OTConnect), don't bind it to a specific address. Rather, use the following code.

err = OTBind(ep, NULL, NULL);

DTS Technote 1145 "Living in a Dynamic TCP/IP Environment" gives the backstory for this.

<http://developer.apple.com/technotes/tn/tn1145.html>

I create a queue of endpoints already bound to local wildcard ports from which I get active endpoints (those initiating a connection) and passive endpoints (those that are handed off the connection to by the listener for incoming connections via OTAccept(). Strangely, I don't see any problems handing off a connection to an already bound endpoint via OTAccept(). I only see my problem on the Mac initiating the connection and issueing the call to OTConnect().

I'll keep playing with this but any more insights from you Quinn in response to my feedback to you would be extremely welcome...even if your feedback is "You are on your own".

Thanks!

Alin Pilkington


S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications, Hardware
_______________________________________________
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.
_______________________________________________
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.

References: 
 >Re: kEADDRINUSEErr and OTConnect() confusion... (From: Quinn <email@hidden>)

  • Prev by Date: Re: socklen_t issue on Panther
  • Next by Date: Re: TCP/IP settings question
  • Previous by thread: Re: kEADDRINUSEErr and OTConnect() confusion...
  • Next by thread: Re: kEADDRINUSEErr and OTConnect() confusion...
  • Index(es):
    • Date
    • Thread