DIRECTORY Commander USING [CommandProc, Register], CommandTool USING [ArgumentVector, Failed, Parse], IO USING [Close, EndOf, EndOfStream, Error, Flush, GetChar, int, PutChar, PutF, PutRope, STREAM], Rope USING [Cat, Find, FromChar, ROPE], UserCredentials USING [Get], IPDefs USING [Address], IPName USING [NameToAddress], TCP USING [AbortTCPStream, CreateTCPStream, Error, ErrorFromStream, neverTimeout, Reason, Timeout, WaitForListenerOpen]; TCPTest: CEDAR PROGRAM IMPORTS Commander, CommandTool, IO, Rope, UserCredentials, IPName, TCP = BEGIN fingerSocket: INT = 79; remoteAddress: IPDefs.Address; remoteSocket: INT _ fingerSocket; running: BOOL _ TRUE; server: PROCESS; SetAddress: Commander.CommandProc = { out: IO.STREAM _ cmd.out; argv: CommandTool.ArgumentVector = CommandTool.Parse[cmd ! CommandTool.Failed => {out.PutRope[errorMsg]; GO TO GiveUp}]; remoteAddresses: LIST OF IPDefs.Address _ IPName.NameToAddress[argv[1]]; IF remoteAddresses=NIL THEN {out.PutRope["Name not found"]; GOTO GiveUp}; remoteAddress _ remoteAddresses.first; out.PutF["[%g.%g.%g.%g]\n", IO.int[remoteAddress[0]], IO.int[remoteAddress[1]], IO.int[remoteAddress[2]], IO.int[remoteAddress[3]]]; EXITS GiveUp => NULL; }; Finger: Commander.CommandProc = { out: IO.STREAM _ cmd.out; fingerStream: IO.STREAM; c: CHAR; cr: TCP.Reason _ neverOpen; { ENABLE { TCP.Timeout => { out.PutRope["[No response.]\n"]; GO TO GiveUp; }; TCP.Error => { cr _ reason; GO TO GiveUp; }; IO.Error => { cr _ TCP.ErrorFromStream[fingerStream]; GOTO GiveUp; }; }; fingerStream _ TCP.CreateTCPStream[[matchLocalPort~FALSE, localPort~0, matchForeignAddr~TRUE, foreignAddress~remoteAddress, matchForeignPort~TRUE, foreignPort~remoteSocket, active~TRUE, timeout~120000]]; TCP.WaitForListenerOpen[fingerStream, TCP.neverTimeout]; fingerStream.PutRope[cmd.commandLine]; fingerStream.PutChar['\l]; -- send the LF as well fingerStream.Flush[]; WHILE NOT fingerStream.EndOf[] DO c _ fingerStream.GetChar[ ! IO.EndOfStream => EXIT]; IF c # '\l THEN out.PutChar[c]; ENDLOOP; fingerStream.Close[]; EXITS GiveUp => SELECT cr FROM remoteAbort => out.PutRope["[Remote host refused to point the finger at its users.]\n"]; ENDCASE => TCP.AbortTCPStream[fingerStream]; }; }; FingerServer: PROC = { ENABLE TCP.Timeout => RESUME; fingerStream: IO.STREAM; WHILE running DO ENABLE BEGIN IO.Error => RETRY; TCP.Timeout => RETRY; TCP.Error => RETRY; END; char: CHAR; rope: Rope.ROPE _ NIL; fingerStream _ TCP.CreateTCPStream[[matchLocalPort: TRUE, localPort: fingerSocket, matchForeignAddr: FALSE, matchForeignPort: FALSE, active: FALSE]]; DO char _ fingerStream.GetChar[]; IF char = '\l THEN EXIT; rope _ Rope.Cat[rope, Rope.FromChar[char]]; ENDLOOP; fingerStream.PutF["User %g logged in on a Dorado.\n\l", [rope[UserCredentials.Get[].name]]]; IF Rope.Find[rope, "Verbose"] # -1 THEN THROUGH [0..20) DO fingerStream.PutF[" 123456789 123456789 123456789 123456789 123456789\n\l"]; ENDLOOP; IF Rope.Find[rope, "Super"] # -1 THEN THROUGH [0..200) DO fingerStream.PutF[" 123456789 123456789 123456789 123456789 123456789\n\l"]; ENDLOOP; fingerStream.Flush[]; fingerStream.Close[]; ENDLOOP; }; Commander.Register["SetTCPAddress", SetAddress, "Tell which remote host to use."]; Commander.Register["Finger", Finger, "Who is on host."]; server _ FORK FingerServer[]; END. „Copyright (C) 1983, 1984 by Xerox Corporation. All rights reserved. The following program was created in 1983 but has not been published within the meaning of the copyright law, is furnished under license, and may not be used, copied and/or disclosed except in accordance with the terms of said license. TCPTest.mesa Last Edited by: Nichols, September 1, 1983 4:43 pm Last Edited by: Taft, January 22, 1984 11:28:59 am PST Last Edited by: HGM, October 6, 1984 10:51:08 pm PDT Hal Murray May 16, 1985 3:16:56 am PDT John Larson, April 14, 1986 11:34:42 pm PST Hack for resting reassembly via echoing to GOONHILLY-ECHO. Send big packets. Κd– "cedar" style˜Icode2šœ―™―head™ J™2J™6J™4Icode™&M™+J™šΟk ˜ Kšœ œ˜(Kšœ œ!˜2KšœœQœ˜aKšœœœ˜'Kšœœ˜Kšœœ ˜Kšœœ˜Kšœœo˜x——šΟnœœ˜Kšœœ!œ˜HKš˜Kšœœ˜Kšœ˜Kšœœ˜!Kšœ œœ˜Kšœœ˜šž œ˜%Kšœœœ ˜˜:KšœΟr œ œœ ˜=—Kšœœœ0˜HKšœœœ!œ ˜IKšœ&˜&Kš œœœœœ˜„š˜Kšœ œ˜—K˜—šžœ˜!KšœœœŸœ˜Kšœœœ˜Kšœœ˜Kšœœ˜K˜˜šœ˜šœ ˜Kšœ ˜ Kšœœ˜ K˜—šœ ˜K˜ Kšœœ˜ K˜—šœ ˜ Kšœœ˜'Kšœ˜ K˜—K˜—Kš œœ!œ œ1œ#œ˜ΛKšœ#œ˜8Kšœ&˜&KšœΟc˜1K˜šœœ˜!Kšœœœ˜4Kšœ œ˜Kšœ˜—K˜š˜šœ ˜ šœ˜K˜XKšœœ˜,———K˜—K˜—šž œœ˜Kšœœ œ˜Kšœœœ˜K˜šœ ˜šœ˜ Kšœ œ˜Kšœ œ˜Kšœ œ˜Kšœ˜—Kšœœ˜ Kšœ œœ˜Kš œœ"œ-œœ œ˜•š˜Kšœ˜Kšœ œœ˜Kšœ+˜+Kšœ˜—K˜\šœ!˜'K™Lšœ ˜K˜LKšœ˜——šœ˜%šœ ˜K˜LKšœ˜——K˜K˜Kšœ˜—K˜—K˜RK˜8Kšœ œ˜Kšœ˜——…— ζΞ