newsuser@lth.se (LTH network news server) (09/19/89)
Here is a context diff to convert at least one version of SGI `dog' to use a point-to-point channel instead of broadcast messages. The file to update is called udpbrdcst.c. The job was done by Per Andersson at Computer Enginnering, Lund Institute of Technology, Lund, Sweden. We are all most grateful for his contribution to mankind. Dag Michael Bruck -- Department of Automatic Control Internet: dag@control.lth.se Lund Institute of Technology P. O. Box 118 Phone: +46 46-108779 S-221 00 Lund, SWEDEN Fax: +46 46-138118 ============================================================================== *** udpbrdcst.old Tue Sep 19 17:14:06 1989 --- udpbrdcst.c Tue Sep 19 17:14:08 1989 *************** *** 1,3 **** --- 1,9 ---- + /* + * Hacked May 19, 1989 by Per Andersson to use point to point communication + * between two specific hosts instead of broadcasts. This was done so that + * machines on different subnets may participate in a dogfight. + */ + #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> *************** *** 22,27 **** --- 28,36 ---- struct sockaddr_in *addr; { struct servent *sp; + struct hostent *hp; /* Added (PA) */ + char *thehost; /* Added (PA) */ + int fd; int on = 1; int arg; *************** *** 36,49 **** perror("socket"); return (-1); } if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { ! perror("setsockopt"); ! close(fd); ! return (-1); } bzero(addr, sizeof(addr)); addr->sin_family = AF_INET; addr->sin_port = sp->s_port; if (bind(fd, addr, sizeof(*addr)) < 0) { perror("bind"); close(fd); --- 45,81 ---- perror("socket"); return (-1); } + /********************************** Removed (PA) *** if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { ! perror("setsockopt"); ! close(fd); ! return (-1); } bzero(addr, sizeof(addr)); addr->sin_family = AF_INET; addr->sin_port = sp->s_port; + ******************************************************/ + + /* New stuff here (PA) */ + + bzero(addr, sizeof(addr)); + thehost = getenv("ENEMY"); + if (!thehost) { + printf("Environment variable ENEMY not set\n"); + close(fd); + return(-1); + } + hp = gethostbyname(thehost); + if (!hp) { + printf("Can't find host to connect to %s\n", thehost); + close(fd); + return(-1); + } + addr->sin_family = AF_INET; + addr->sin_port = sp->s_port; + + /* End of new stuff (PA) */ + if (bind(fd, addr, sizeof(*addr)) < 0) { perror("bind"); close(fd); *************** *** 50,56 **** return (-1); } ! addr->sin_addr.s_addr = INADDR_BROADCAST; if (ioctl(fd, FIONBIO, &on) < 0) { /* Turn on non-blocking I/O */ perror("ioctl"); --- 82,89 ---- return (-1); } ! /* addr->sin_addr.s_addr = INADDR_BROADCAST; *** Removed (PA) */ ! bcopy(hp->h_addr, &addr->sin_addr, sizeof(addr->sin_addr)); /* New (PA) */ if (ioctl(fd, FIONBIO, &on) < 0) { /* Turn on non-blocking I/O */ perror("ioctl"); -- Department of Automatic Control Internet: dag@control.lth.se Lund Institute of Technology P. O. Box 118 Phone: +46 46-108779 S-221 00 Lund, SWEDEN Fax: +46 46-138118
sjm@cs.purdue.EDU (Scott J Mark) (09/19/89)
In article <1989Sep19.151924.20792@lth.se> dag@Control.LTH.Se (Dag Bruck) writes: > >Here is a context diff to convert at least one version of SGI `dog' >to use a point-to-point channel instead of broadcast messages. Just last night we got our version of dog to fake a multicast to each machine that is playing. If there's enough interest in it, I'll try to post a how-to. You'll have to have source code to do this. The reason I don't post a straight diff is that, from my understanding, there are more-recent versions of the source than the 2.3 version I got from SGI last month. That is, more-recent for those who aren't on PI machines. Currently, we keep a list of the connected machines, and then send a point-to-point to each machine. It doesn't seem to slow our game down at all, and I've, uh, "boosted" the packet size to allow multiple teams and multiple missiles. So if your network isn't saturated this may be a solution to the broadcast/interrupt problem. I haven't yet had time to add "defect" code, to stop sending packets to machines where people have stopped playing. So far throwing packets at the ethernet hasn't been a problem. Scott Mark PLEASE use E-Mail to express interest. -- sjm@cs.purdue.edu