* tcp with TERM support for linux
@ 1993-08-22 18:39 William M. Perry
0 siblings, 0 replies; only message in thread
From: William M. Perry @ 1993-08-22 18:39 UTC (permalink / raw)
Hello all,
I was trying to do some emacs lisp development while at home on my
linux box and needed to use open-network-stream within it. Problem
is, I use TERM to dialup to my schools computers since I am not
directly on the internet from home (I wish :) For those of you not
familiar with TERM, it is similar to SLIP, but you don't need a
dedicated modem on the other end, or an ip #, etc. You can redirect X
displays over it, and redirect ports from the host machine to your
machine at home, and vice versa. Very handy utility. You can ftp it
from sunsite.unc.edu:/pub/Linux/apps/comm/term/term/term107.tar.Z
Since my linux box is not directly on the net, I couldn't use open
network stream, and I hate emulating it by using a term-ified telnet
in a subprocess. So I took the tcp.c program by Masanobu UMEDA and
term-ified it. This file is basically a stripped down version of
telnet that only takes input and spews out output, with no ^Ms tacked
on the end, which is an added bonus. :) There is a corresponding
tcp.el file which will overload the definition of open-network-stream
to use this program in a subprocess.
I will mail these patches off to Masanobu UMEDA in a few minutes
also, to see if he can merge them in the main release of this (which
is now part of emacs 19)
For now, you need the term client.a library, and the include file
client.h from the term distribution. If you define TERM when you
compile, it will compile with term support. If you define
TERM_COMPRESS, term will use compression also. This is the line I
used to compile on my system (i renamed client.a to libclient.a):
gcc -I/usr/src/term -L/usr/src/term -DTERM -DTERM_COMPRESS tcp.c -o \
tcp -lclient
and it works... the only problem is that it can't recognize when a
host can't be reached - just sort of hangs. This has something to do
with Term not reporting the error (I think - please correct me if I am
wrong)
The patches aren't very long, so I will include them at the end of
this article. The patches, as well as the full source will be
available from cs.indiana.edu:/pub/elisp/tcp/* in a matter of minutes.
I am thinking of trying to merge this into the actual source code of
emacs also - was extremely simple to convert. Anybody from the fsf
want to comment on whether this could be folded into the main release
of emacs? Can #define TERM in s/linux.h or something . . . I'll
mail rms later today, but I believe he is out of country (india?) for
a while.
Hope some people find this of use,
Bill P.
------------------------------- Patch -------------------------------
*** puretcp.c Sat Aug 21 17:40:15 1993
--- mytcp.c Sat Aug 21 17:27:19 1993
***************
*** 33,38 ****
--- 33,42 ----
* cc -O -o tcp tcp.c -DFUJITSU_UTS -lu -lsocket
*/
+ /*
+ Modified by William Perry (wmperry@indiana.edu) to use term
+ */
+
#ifndef lint
static char *rcsId = "$Header: tcp.c,v 1.3 89/06/19 13:39:12 umerin Locked $";
#endif
***************
*** 75,80 ****
--- 79,88 ----
}
#endif
+ #ifdef TERM
+ #include "client.h"
+ #endif /* TERM */
+
main(argc, argv)
int argc;
char *argv[];
***************
*** 119,128 ****
--- 127,139 ----
}
}
+ #ifndef TERM
if((host = gethostbyname(hostname)) == NULL){
perror("gethostbyname");
exit(1);
}
+ #endif /* TERM */
+
if(isdigit(service[0]))
port = atoi(service);
else {
***************
*** 134,143 ****
--- 145,159 ----
port = serv->s_port;
}
+ #ifndef TERM
bzero(&sockin, sizeof(sockin));
sockin.sin_family = host->h_addrtype;
bcopy(host->h_addr, &sockin.sin_addr, host->h_length);
+ #endif
+
sockin.sin_port = htons(port);
+
+ #ifndef TERM
if((server = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
perror("socket");
exit(1);
***************
*** 158,164 ****
close(server);
exit(1);
}
!
#ifdef O_NDELAY
fcntl(server, F_SETFL, O_NDELAY);
--- 174,192 ----
close(server);
exit(1);
}
! #else
! if ((server = connect_server(0)) < 0) {
! perror("tcp: connect to term server");
! return(1);
! }
! printf("%s:%d",hostname,ntohs(sockin.sin_port));
! send_command(server,C_PORT,0,"%s:%d",hostname,ntohs(sockin.sin_port));
! #ifdef TERM_COMPRESS
! send_command(server,C_COMPRESS,1,"y");
! #endif /* TERM COMPRESS */
! send_command(server,C_DUMB,1,0);
! #endif /*TERM*/
!
#ifdef O_NDELAY
fcntl(server, F_SETFL, O_NDELAY);
--
Send submissions for comp.os.linux.announce to: linux-announce@tc.cornell.edu
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1993-08-22 18:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-08-22 18:39 tcp with TERM support for linux William M. Perry
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox