[Spread-users] send text to spread group from command line?

George Schlossnagle george at omniti.com
Fri Aug 17 15:05:49 EDT 2001


Thanks.  I don't do a connect in my while loop.  It's one connect at the
beginning and then you loop doing fgets(,,stdin) and send to spread, so the
overhead in this application should be really low.

----- Original Message -----
From: "Yair Amir" <yairamir at cnds.jhu.edu>
To: "George Schlossnagle" <george at omniti.com>
Cc: "Monte Ohrt" <monte at ispi.net>; "spread mailing list"
<spread-users at lists.spread.org>
Sent: Friday, August 17, 2001 2:59 PM
Subject: Re: [Spread-users] send text to spread group from command line?


> Hi,
>
> Thanks George.
>
> I would add two more lines to this code (although not practically
necessary today) for
> disconnection (see the edit in the code below).
>
> Note that in regular operation, if you intend to send many
> messages per second using this kind of method, perl or no perl,
> there will be considerable overhead associated with it.
> This is because each time there will be a connection and disconnection
with Spread.
> Now, connecting to Spread is much much more expensive than just sending a
message.
>
> Regularly, Spread should be used in most cases in a way that you connect
with it.
>
> There was some discussion a few weeks ago on this list I think, and we
talked a bit
> about this in our group, about developing a publishing method, where the
sending
> entity will not be a fully privilege client (for example, it will not be
able to
> join groups or receive message). With such method, there will not be a
need to
> connect and this will not be more expensive then sending a message. (Theo
talked
> about some shared memory solutions).
>
> Cheers,
>
> :) Yair. http://www.cnds.jhu.edu
>
> George Schlossnagle wrote:
> >
> > There's not one that ships with Spread, but it's simple enough to write.
> > Here's a short one:
> >
> > #include "stdio.h"
> > #include "stdlib.h"
> > #include <unistd.h>
> > #include "string.h"
> > #include "sp.h"
> >
> > void usage(char *s)
> > {
> >     fprintf(stderr, "%s -g <group> -s server\n", s);
> > }
> >
> > int main(int argc, char **argv)
> > {
> >     char *server = 0;
> >     char *group = 0;
> >     char line[1024];
> >     char privatename[MAX_GROUP_NAME];
> >     char privategroup[MAX_GROUP_NAME];
> >     int retval;
> >     int getoption;
> >     mailbox mbox;
> >
> >     while((getoption = getopt(argc, argv, "g:s:h:")) != -1) {
> >         switch(getoption)
> >         {
> >             case 'g':
> >                 group = optarg;
> >                 break;
> >             case 's':
> >                 server = optarg;
> >                 break;
> >             default:
> >                 usage(argv[0]);
> >                 return -1;
> >                 break;
> >         }
> >     }
> >     if( group == 0 || server == 0) {
> >         usage(argv[0]);
> >         return -1;
> >     }
> >     snprintf(privatename, MAX_GROUP_NAME, "sp_client_%d", getpid());
> >     if((retval = SP_connect(server, privatename, 0, 0, &mbox,
privategroup))
> > <
> > 0 )
> >     {
> >         SP_error(retval);
> >         return -1;
> >     }
> >     while(fgets(line, 1024, stdin)) {
> >         fprintf(stderr, "%s", line);
> >         if((retval = SP_multicast( mbox, RELIABLE_MESS, group, 1,
> > strlen(line),
> >             line)) < 0)
> >         {
> >             SP_error(retval);
>       SP_disconnect( mbox );
> >             return -1;
> >         }
> >     }
>       SP_disconnect( mbox );
> > }
> >
> > name it sp_client.c and compile it with
> > gcc -c sp_client.c
> > gcc -o sp_client sp_client.o -lsp
> >
> > ----- Original Message -----
> > From: "Monte Ohrt" <monte at ispi.net>
> > To: "spread mailing list" <spread-users at lists.spread.org>
> > Sent: Friday, August 17, 2001 12:39 PM
> > Subject: [Spread-users] send text to spread group from command line?
> >
> > > Is there a way to send text to a spread group from the command line? I
> > > guess I'm asking if there is a non-interactive client that can take
> > > input like so:
> > >
> > > spread_client -g groupname -s 4803 < input.txt
> > >
> > > or:
> > >
> > > echo input.txt | spread_client -g groupname -s 4803
> > >
> > > If there _is_ such a client, could this be used in apache for
spreading
> > > the error_logs instead of the perl script that comes with
> > > mod_log_spread? I'm trying to avoid perl :-)
> > >
> > > ErrorLog = "|/path/to/spread_client -g group -s port"
> > >
> > > --
> > > Monte Ohrt <monte at ispi.net>
> > > http://www.ispi.net/
> > >
> > >
> > > _______________________________________________
> > > spread-users mailing list
> > > spread-users at lists.spread.org
> > > http://lists.spread.org/mailman/listinfo/spread-users
> > >
> >
> > _______________________________________________
> > spread-users mailing list
> > spread-users at lists.spread.org
> > http://lists.spread.org/mailman/listinfo/spread-users
>







More information about the Spread-users mailing list