[comp.unix.wizards] Local daemon socket

warlock@csuchico.edu (John Kennedy) (03/07/90)

  I'm looking for a way to make a daemon executable on more than one machine.
Currently I'm using the following code:

	.....
	.
        servsock = socket( AF_INET, SOCK_STREAM, 0 );
        CHECK( servsock, SOCK_FAIL, "socket()" );
        server.sin_family = AF_INET;
        server.sin_addr.s_addr = htonl( INADDR_ANY );
        server.sin_port = htons( (u_short) sockaddr );
        length = sizeof( struct sockaddr_in );
        result = bind( servsock, (struct sockaddr *) &server, length );
        servsock = socket( AF_INET, SOCK_STREAM, 0 );
        CHECK( result, SOCK_FAIL, "bind()" );
	.
	.....

  If I only have one daemon running on the network, it's fine.  If I have two
or more, they fail to bind the socket (Address already in use).  I'd like to
limit the daemon so that other daemon's may be run on different host machines.

--
Warlock, AKA              +----------------------------------------------------
John Kennedy              | uucp:     lampoon!warlock@csuchico.edu
CSCI Student	          | internet: warlock@csuchico.edu
CSU Chico                 +----------------------------------------------------

madd@world.std.com (jim frost) (03/08/90)

warlock@csuchico.edu (John Kennedy) writes:
>  I'm looking for a way to make a daemon executable on more than one machine.
[...]
>  If I only have one daemon running on the network, it's fine.  If I have two
>or more, they fail to bind the socket (Address already in use).  I'd like to
>limit the daemon so that other daemon's may be run on different host machines.

It doesn't look as though it should fail if run on different machines,
only if run on the same machine.

I can't give you any advice as to what's the matter with your code,
but I *do* have a tutorial with code fragments that show how to
properly set up an AF_INET SOCK_STREAM server/client pair and to
communicate between them.  I also have a full application -- a network
message system like "rsend" -- which I could send to you as a further
example.  Interested?  If so, please contact me via email.

jim frost
saber software
jimf@saber.com