diff options
author | joerg <joerg@FreeBSD.org> | 1996-03-09 19:23:01 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1996-03-09 19:23:01 +0000 |
commit | a12cf8aa0e1029b87db1d40e09450d0d09635334 (patch) | |
tree | 05d5824bd651018bd12409c9b3fa9369e6f2c193 /usr.bin/talk/io.c | |
parent | 17cc9fc50275a82f4224ba957d768981a45929d7 (diff) | |
download | FreeBSD-src-a12cf8aa0e1029b87db1d40e09450d0d09635334.zip FreeBSD-src-a12cf8aa0e1029b87db1d40e09450d0d09635334.tar.gz |
Make talk automagically find out the interface IP address where the
remote peer will be connected through. This avoids the ``Checking for
invitation on caller's machine'' problem for multi-homed hosts.
Thanks to: Garrett, for his `find_interface' example
Diffstat (limited to 'usr.bin/talk/io.c')
-rw-r--r-- | usr.bin/talk/io.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.bin/talk/io.c b/usr.bin/talk/io.c index f7f31bd..f608654 100644 --- a/usr.bin/talk/io.c +++ b/usr.bin/talk/io.c @@ -49,28 +49,28 @@ static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93"; #include "talk.h" #define A_LONG_TIME 10000000 -#define STDIN_MASK (1<<fileno(stdin)) /* the bit mask for standard - input */ /* * The routine to do the actual talking */ +void talk() { - register int read_template, sockt_mask; - int read_set, nb; + int nb; + fd_set read_set, read_template; char buf[BUFSIZ]; struct timeval wait; message("Connection established\007\007\007"); current_line = 0; - sockt_mask = (1<<sockt); /* * Wait on both the other process (sockt_mask) and * standard input ( STDIN_MASK ) */ - read_template = sockt_mask | STDIN_MASK; + FD_ZERO(&read_template); + FD_SET(sockt, &read_template); + FD_SET(fileno(stdin), &read_template); for (;;) { read_set = read_template; wait.tv_sec = A_LONG_TIME; @@ -85,7 +85,7 @@ talk() p_error("Unexpected error from select"); quit(); } - if (read_set & sockt_mask) { + if (FD_ISSET(sockt, &read_set)) { /* There is data on sockt */ nb = read(sockt, buf, sizeof buf); if (nb <= 0) { @@ -94,7 +94,7 @@ talk() } display(&his_win, buf, nb); } - if (read_set & STDIN_MASK) { + if (FD_ISSET(fileno(stdin), &read_set)) { /* * We can't make the tty non_blocking, because * curses's output routines would screw up @@ -115,6 +115,7 @@ extern int sys_nerr; * p_error prints the system error message on the standard location * on the screen and then exits. (i.e. a curses version of perror) */ +void p_error(string) char *string; { @@ -130,6 +131,7 @@ p_error(string) /* * Display string in the standard location */ +void message(string) char *string; { |