• 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: Getting error info when NSSocketPort initWithTCPPort fails
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting error info when NSSocketPort initWithTCPPort fails


  • Subject: Re: Getting error info when NSSocketPort initWithTCPPort fails
  • From: Rick Hoge <email@hidden>
  • Date: Fri, 30 Jul 2004 07:59:03 -0400

Thanks very much for the suggestions, Wade

Turns out this was (what else?) a series of dumb mistakes on my part. Checking in /etc/services on the problem systems revealed a conflict with another service that must have been intermittently polling the port. The port number I was using on those systems was one persisting from code snippets I'd grabbed from tutorial examples - certainly a *bad* idea.

In retrospect it's kind of funny/scary that virtually all the tutorial examples or code snippets i found posted in discussion forums did not test for the return value of initWithTCPPort:. In the one case where there was a test, it was an if (thePort != nil) block with no else for handling the nil case. Of course ultimately this is my fault for not paying more careful attention to this (and it's possible I missed some better examples), but to anyone else out there coding this stuff - don't assume initWithTCPPort: won't return nil!

If it's the problem I've suggested, that won't be of much help. Trying different ports should resolve the issue in any case, so if your program can handle that (i.e. it uses Rendezvous anyway, so a known port is unnecessary) then by all means.

I notice that the simple 'init' method for the NSSocketPort class has the following description:

Initializes the receiver as a local TCP/IP socket of type SOCK_STREAM. The port number is selected by the system.

It sounds like this would take care of the port testing and return the first available port found.

Wade Tregaskis (aim: wadetregaskis)
-- Sed quis custodiet ipsos custodes?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Getting error info when NSSocketPort initWithTCPPort fails
      • From: Wade Tregaskis <email@hidden>
References: 
 >Getting error info when NSSocketPort initWithTCPPort fails (From: Rick Hoge <email@hidden>)

  • Prev by Date: Re: Crash with NSPrintOperation ?!
  • Next by Date: Re: Getting error info when NSSocketPort initWithTCPPort fails
  • Previous by thread: Re: Getting error info when NSSocketPort initWithTCPPort fails
  • Next by thread: Re: Getting error info when NSSocketPort initWithTCPPort fails
  • Index(es):
    • Date
    • Thread