[lug] socket programming/kernel question

Michael J. Hammel mjhammel at graphics-muse.org
Wed Mar 5 07:37:35 MST 2003


On Tue, 2003-03-04 at 18:45, Bear Giles wrote:
> Any networking or kernel experts around?
> 
> If I have a stream connection and the other side disconnects, my 
> process gets an EPIPE signal.  That's simple to catch and use to 
> release resources.
> 
> But what about a datagram Unix socket?  There's no connection, per 
> se, but I can use the SCM_CREDENTIALS to get the PID of the 
> caller.  The kernel will know when that process dies.  Is there 
> any way for my process to get a signal then an arbitrary process dies?

You have two processes that know about each other, correct?  Or does
your process know about the others, but the others don't know about
you?  I'm guessing the former, based on your description.

If both know about each other but you want asyncronous message handling,
then TCP is the best way to go about it.  EPIPE can be used to know when
the opposite end goes away.  Trying to do it by process id is far more
difficult.  With TCP you can use your own ID scheme that isn't dependent
on the OS (which means cross platform and remote system handling is
possible).

I find that UDP is better for situations where the sender doesn't care
about the receivers status.  This doesn't sound like the case here.

-- 
Michael J. Hammel                               The Graphics Muse 
mjhammel at graphics-muse.org                      http://www.graphics-muse.com
------------------------------------------------------------------------------
Football commentator and former player Joe Theismann, 1996: "Nobody in
football should be called a genius. A genius is a guy like Norman
Einstein."



More information about the LUG mailing list