• 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
Implementing a TCP port listener in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implementing a TCP port listener in Cocoa


  • Subject: Implementing a TCP port listener in Cocoa
  • From: Rick Hoge <email@hidden>
  • Date: Wed, 28 Jun 2006 10:06:31 -0400


I would like to implement an internet service from within a Cocoa application such that when a remote client requests a connection on a certain port the connection and subsequent service will be handled by the Cocoa application.


I want to do this using Cocoa Foundation classes if possible, but it's not really clear from the documentation how to set this up. Most of the documentation is geared towards Distributed Objects (DO) and not provision of a TCP port service in the classic Unix sense.

Basically I'm trying achieve functionality I had with an older inetd- based program I have that allows images to be sent from one computer to another using the DICOM medical imaging protocol. I want to get rid of the inetd-based server and just allow the images to be opened or handled directly by my Cocoa app when they are sent by a remote host. Of course with inetd it's easy - inetd will just hook your stdin/stdout/stderr to the appropriate sockets when needed and you don't have to deal with listening. I'm not so sure how to handle this part in Cocoa however.

I have already written a service that uses DO, and which uses the following code to set up a listener on THE_PORT

NSSocketPort *receivePort = [[NSSocketPort alloc] initWithTCPPort:THE_PORT];

NSConnection *theConnection = [[NSConnection alloc] initWithReceivePort:receivePort sendPort:nil];

	[receivePort release];

	[theConnection setDelegate:self];
	[theConnection setRootObject:self];

All this works great for sending Obj-C messages between processes, but I'm not sure what the analogous approach would be to allow for remote connections like DICOM. Should I use NSSocketPort and NSConnection? Or maybe NSStream?

Thanks in advance for any suggestions or pointers to relevant documentation!

Rick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Implementing a TCP port listener in Cocoa
      • From: Dustin Voss <email@hidden>
    • Re: Implementing a TCP port listener in Cocoa
      • From: Jakob Olesen <email@hidden>
  • Prev by Date: QuartzComposerWWDC
  • Next by Date: Re: RTF incompatibilites Windows/NSAttributesString RTFFromRange:...
  • Previous by thread: QuartzComposerWWDC
  • Next by thread: Re: Implementing a TCP port listener in Cocoa
  • Index(es):
    • Date
    • Thread