Re: Implementing a TCP port listener in Cocoa
Re: Implementing a TCP port listener in Cocoa
- Subject: Re: Implementing a TCP port listener in Cocoa
- From: Greg Herlihy <email@hidden>
- Date: Thu, 29 Jun 2006 22:52:23 -0700
- Thread-topic: Implementing a TCP port listener in Cocoa
By far the most practical option is to write the software as an xinetd
service and place its configuration file in /etc/xinet.d (where it will be
migrated to the set of launchd's services on Tiger). As an xinetd service,
practically all of the complicated issues regarding network connections,
secure interfaces, load balancing, and load constraints are handled by the
xinetd server itself based on the settings specified in the service's
configuration file. Consult the xinetd and related man pages (or its web
site) for details.
With all the hard problems out of the way, all that is left for the service
writer is to implement a single-threaded program that does nothing more than
read from stdin and write to stdout. The task of writing the equivalent of a
network server couldn't be made any more simple - while the task of writing
a standalone program that would be as tested, secure, scalable, and
configurable as the xinetd/launchd server - could not be made any more
difficult.
After all, it doesn't make a lot of sense for every software program that
listens for a connection to implement its own server. It's more sensible
just to take advantage of the server that the OS is already running - that's
why it's running in the first place.
Greg
On 6/29/06 5:44 AM, "Rick Hoge" <email@hidden> wrote:
>
> ...
>
>> Alternatively, set up the listening socket in your app, and use
>> NSTask to run your inetd daemon. NSTask lets you hook up stdin and
>> stdout before launching. It ought to work with a socket, I haven't
>> tried it.
>
> Thanks very much for this comprehensive description of TCP server
> architectures.
>
> In my case the old inetd program is kind of a mess and not well
> suited for my current needs, but the library it uses for 'speaking'
> the DICOM protocol is pretty good (and beyond my ability to re-
> write). The only difficulty is that the library is really set up to
> communicate by way of files.
>
> Probably your last suggestion would work well in my situation - I can
> re-write the outer 'server' layer using the libraries and launch this
> using NSTask.
>
> 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
_______________________________________________
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