From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d4db,1cd2b1a534c0f545,start X-Google-Attributes: gid10d4db,public X-Google-ArrivalTime: 1993-08-22 11:39:35 PST Path: gmd.de!newsserver.jvnc.net!howland.reston.ans.net!vixen.cso.uiuc.edu!sdd.hp.com!caen!batcomputer!bounce-bounce From: wmperry@mango.ucs.indiana.edu (William M. Perry) Newsgroups: comp.os.linux.announce Subject: tcp with TERM support for linux Followup-To: comp.os.linux Date: 22 Aug 1993 14:39:04 -0400 Organization: Computer Science, Indiana University Sender: mdw@TC.Cornell.EDU Message-ID: <258eg8$epc@theory.TC.Cornell.EDU> Reply-To: wmperry@mango.ucs.indiana.edu (William M. Perry) NNTP-Posting-Host: theory.tc.cornell.edu Keywords: TERM, tcp, TCP/IP, communications, networking 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