/* $Id: trigger.C,v 1.2 2000/08/25 22:25:29 fubob Exp $ */ /* Use this program to simulate a herd of SFSRO clients. You can then test the maximum number of sustainable connections per second to an SFSRO server. Warning. this is almost as fast as a plain TCP connections. Running longer than 1/2 second will likely use up resources. */ /* * * Copyright (C) 2000 Kevin Fu (fubob@mit.edu) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * */ #include #include //#include "sfsmisc.h" #include "amisc.h" int main (int argc, void *argv[]) { if (argc != 2) { warn << "Usage: " << static_cast(argv[0]) << "-t : Trigger on this port\n" << "Assumes that broadcast is 18.26.7.255\n"; exit (-1); } int udpsock = inetsocket (SOCK_DGRAM); if (udpsock < 0) { fatal ("socket"); } int broadcast = 1; if (setsockopt (udpsock, SOL_SOCKET, SO_BROADCAST, &broadcast, sizeof (broadcast)) < 0) fatal ("setsockopt: %m\n"); char buf[1]; bzero (buf, 1); sockaddr_in to; bzero (&to, sizeof (to)); to.sin_family = AF_INET; // to.sin_port = htons (atoi (static_cast(argv[1]))); to.sin_port = htons (6667); inet_aton ("18.26.7.255", &to.sin_addr); int tolen = sizeof(to); int err; if ((err = sendto (udpsock, buf, 1, 0, (struct sockaddr*)&to, tolen)) < 0) { warn << "Error: " << err << "\n"; fatal ("sendto: %m\n"); } return 0; }