home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume8 / bug < prev    next >
SHell self-extracting ARchive  |  1989-10-01  |  9.3 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: SHell self-extracting ARchive (archive/shar).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file C source text default
99% file C source, ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000010| 2e 73 6f 75 72 63 65 73 | 2e 6d 69 73 63 0a 73 75 |.sources|.misc.su|
|00000020| 62 6a 65 63 74 3a 20 76 | 30 38 69 30 36 34 3a 20 |bject: v|08i064: |
|00000030| 62 75 67 20 2d 2d 20 6d | 61 6b 65 20 61 20 74 72 |bug -- m|ake a tr|
|00000040| 61 6e 73 63 72 69 70 74 | 20 6f 66 20 61 20 73 6f |anscript| of a so|
|00000050| 63 6b 65 74 20 63 6f 6e | 6e 65 63 74 69 6f 6e 0a |cket con|nection.|
|00000060| 66 72 6f 6d 3a 20 61 6c | 6c 62 65 72 79 40 75 75 |from: al|lbery@uu|
|00000070| 6e 65 74 2e 55 55 2e 4e | 45 54 20 28 42 72 61 6e |net.UU.N|ET (Bran|
|00000080| 64 6f 6e 20 53 2e 20 41 | 6c 6c 62 65 72 79 20 2d |don S. A|llbery -|
|00000090| 20 63 6f 6d 70 2e 73 6f | 75 72 63 65 73 2e 6d 69 | comp.so|urces.mi|
|000000a0| 73 63 29 0a 52 65 70 6c | 79 2d 54 6f 3a 20 6d 61 |sc).Repl|y-To: ma|
|000000b0| 74 74 68 65 77 40 43 53 | 2e 55 43 4c 41 2e 45 44 |tthew@CS|.UCLA.ED|
|000000c0| 55 20 28 4d 61 74 74 68 | 65 77 20 4d 65 72 7a 62 |U (Matth|ew Merzb|
|000000d0| 61 63 68 65 72 29 0a 0a | 50 6f 73 74 69 6e 67 2d |acher)..|Posting-|
|000000e0| 6e 75 6d 62 65 72 3a 20 | 56 6f 6c 75 6d 65 20 38 |number: |Volume 8|
|000000f0| 2c 20 49 73 73 75 65 20 | 36 34 0a 53 75 62 6d 69 |, Issue |64.Submi|
|00000100| 74 74 65 64 2d 62 79 3a | 20 6d 61 74 74 68 65 77 |tted-by:| matthew|
|00000110| 40 43 53 2e 55 43 4c 41 | 2e 45 44 55 20 28 4d 61 |@CS.UCLA|.EDU (Ma|
|00000120| 74 74 68 65 77 20 4d 65 | 72 7a 62 61 63 68 65 72 |tthew Me|rzbacher|
|00000130| 29 0a 41 72 63 68 69 76 | 65 2d 6e 61 6d 65 3a 20 |).Archiv|e-name: |
|00000140| 62 75 67 0a 0a 23 21 20 | 2f 62 69 6e 2f 73 68 0a |bug..#! |/bin/sh.|
|00000150| 23 20 54 68 69 73 20 69 | 73 20 61 20 73 68 65 6c |# This i|s a shel|
|00000160| 6c 20 61 72 63 68 69 76 | 65 2c 20 6d 65 61 6e 69 |l archiv|e, meani|
|00000170| 6e 67 3a 0a 23 20 31 2e | 20 52 65 6d 6f 76 65 20 |ng:.# 1.| Remove |
|00000180| 65 76 65 72 79 74 68 69 | 6e 67 20 61 62 6f 76 65 |everythi|ng above|
|00000190| 20 74 68 65 20 23 21 20 | 2f 62 69 6e 2f 73 68 20 | the #! |/bin/sh |
|000001a0| 6c 69 6e 65 2e 0a 23 20 | 32 2e 20 53 61 76 65 20 |line..# |2. Save |
|000001b0| 74 68 65 20 72 65 73 75 | 6c 74 69 6e 67 20 74 65 |the resu|lting te|
|000001c0| 78 74 20 69 6e 20 61 20 | 66 69 6c 65 2e 0a 23 20 |xt in a |file..# |
|000001d0| 33 2e 20 45 78 65 63 75 | 74 65 20 74 68 65 20 66 |3. Execu|te the f|
|000001e0| 69 6c 65 20 77 69 74 68 | 20 2f 62 69 6e 2f 73 68 |ile with| /bin/sh|
|000001f0| 20 28 6e 6f 74 20 63 73 | 68 29 20 74 6f 20 63 72 | (not cs|h) to cr|
|00000200| 65 61 74 65 20 74 68 65 | 20 66 69 6c 65 73 3a 0a |eate the| files:.|
|00000210| 23 09 52 45 41 44 4d 45 | 0a 23 09 62 75 67 2e 31 |#.README|.#.bug.1|
|00000220| 0a 23 09 62 75 67 2e 63 | 0a 23 20 54 68 69 73 20 |.#.bug.c|.# This |
|00000230| 61 72 63 68 69 76 65 20 | 63 72 65 61 74 65 64 3a |archive |created:|
|00000240| 20 46 72 69 20 53 65 70 | 20 32 39 20 31 38 3a 32 | Fri Sep| 29 18:2|
|00000250| 39 3a 35 32 20 31 39 38 | 39 0a 65 78 70 6f 72 74 |9:52 198|9.export|
|00000260| 20 50 41 54 48 3b 20 50 | 41 54 48 3d 2f 62 69 6e | PATH; P|ATH=/bin|
|00000270| 3a 24 50 41 54 48 0a 69 | 66 20 74 65 73 74 20 2d |:$PATH.i|f test -|
|00000280| 66 20 27 52 45 41 44 4d | 45 27 0a 74 68 65 6e 0a |f 'READM|E'.then.|
|00000290| 09 65 63 68 6f 20 73 68 | 61 72 3a 20 77 69 6c 6c |.echo sh|ar: will|
|000002a0| 20 6e 6f 74 20 6f 76 65 | 72 2d 77 72 69 74 65 20 | not ove|r-write |
|000002b0| 65 78 69 73 74 69 6e 67 | 20 66 69 6c 65 20 22 27 |existing| file "'|
|000002c0| 52 45 41 44 4d 45 27 22 | 0a 65 6c 73 65 0a 63 61 |README'"|.else.ca|
|000002d0| 74 20 3c 3c 20 5c 53 48 | 41 52 5f 45 4f 46 20 3e |t << \SH|AR_EOF >|
|000002e0| 20 27 52 45 41 44 4d 45 | 27 0a 42 75 67 20 69 73 | 'README|'.Bug is|
|000002f0| 20 75 73 65 64 20 74 6f | 20 74 61 70 20 61 20 73 | used to| tap a s|
|00000300| 74 72 65 61 6d 20 73 6f | 63 6b 65 74 2e 20 20 49 |tream so|cket. I|
|00000310| 74 20 69 73 20 75 73 65 | 66 75 6c 20 66 6f 72 20 |t is use|ful for |
|00000320| 74 72 61 63 69 6e 67 20 | 63 6f 6d 6d 75 6e 69 63 |tracing |communic|
|00000330| 61 74 69 6f 6e 20 0a 62 | 65 74 77 65 65 6e 20 61 |ation .b|etween a|
|00000340| 20 73 65 72 76 65 72 20 | 61 6e 64 20 69 74 73 20 | server |and its |
|00000350| 63 6c 69 65 6e 74 73 2e | 20 20 54 68 65 20 63 6f |clients.| The co|
|00000360| 6d 6d 75 6e 69 63 61 74 | 69 6f 6e 20 62 65 74 77 |mmunicat|ion betw|
|00000370| 65 65 6e 20 73 65 72 76 | 65 72 20 61 6e 64 0a 63 |een serv|er and.c|
|00000380| 6c 69 65 6e 74 20 69 73 | 20 6d 61 69 6e 74 61 69 |lient is| maintai|
|00000390| 6e 65 64 20 77 68 69 6c | 65 20 74 72 61 6e 73 63 |ned whil|e transc|
|000003a0| 72 69 70 74 73 20 6f 66 | 20 61 6c 6c 20 63 6f 6d |ripts of| all com|
|000003b0| 6d 75 6e 69 63 61 74 69 | 6f 6e 20 6c 69 6e 65 73 |municati|on lines|
|000003c0| 20 61 72 65 20 74 61 6b | 65 6e 2e 0a 0a 54 68 65 | are tak|en...The|
|000003d0| 72 65 20 69 73 20 61 20 | 6d 61 6e 20 70 61 67 65 |re is a |man page|
|000003e0| 20 28 62 75 67 2e 31 29 | 2c 20 61 20 73 6f 75 72 | (bug.1)|, a sour|
|000003f0| 63 65 20 66 69 6c 65 20 | 28 62 75 67 2e 63 29 20 |ce file |(bug.c) |
|00000400| 61 6e 64 20 74 68 69 73 | 20 66 69 6c 65 20 28 52 |and this| file (R|
|00000410| 45 41 44 4d 45 29 0a 69 | 6e 63 6c 75 64 65 64 20 |EADME).i|ncluded |
|00000420| 69 6e 20 74 68 69 73 20 | 61 72 63 68 69 76 65 2e |in this |archive.|
|00000430| 20 20 4e 6f 20 4d 61 6b | 65 66 69 6c 65 20 69 73 | No Mak|efile is|
|00000440| 20 6e 65 63 65 73 73 61 | 72 79 2c 20 73 69 6e 63 | necessa|ry, sinc|
|00000450| 65 20 74 6f 20 22 6d 61 | 6b 65 22 20 69 74 2c 20 |e to "ma|ke" it, |
|00000460| 61 6c 6c 0a 79 6f 75 20 | 64 6f 20 69 73 3a 0a 20 |all.you |do is:. |
|00000470| 20 20 20 63 63 20 2d 6f | 20 62 75 67 20 62 75 67 | cc -o| bug bug|
|00000480| 2e 63 0a 0a 59 6f 75 20 | 6e 65 65 64 20 74 6f 20 |.c..You |need to |
|00000490| 62 65 20 72 75 6e 6e 69 | 6e 67 20 61 20 42 53 44 |be runni|ng a BSD|
|000004a0| 20 6f 72 20 42 53 44 2d | 64 65 72 69 76 65 64 20 | or BSD-|derived |
|000004b0| 73 79 73 74 65 6d 20 28 | 73 69 6e 63 65 20 69 74 |system (|since it|
|000004c0| 20 65 78 61 6d 69 6e 65 | 73 20 73 6f 63 6b 65 74 | examine|s socket|
|000004d0| 73 29 2e 0a 49 74 20 68 | 61 73 20 62 65 65 6e 20 |s)..It h|as been |
|000004e0| 74 65 73 74 65 64 20 75 | 6e 64 65 72 20 53 75 6e |tested u|nder Sun|
|000004f0| 4f 53 20 34 2e 30 2e 33 | 0a 0a 49 66 20 79 6f 75 |OS 4.0.3|..If you|
|00000500| 20 64 6f 6e 27 74 20 6c | 69 6b 65 20 6d 79 20 4d | don't l|ike my M|
|00000510| 41 52 4b 2c 20 79 6f 75 | 20 63 61 6e 20 63 68 61 |ARK, you| can cha|
|00000520| 6e 67 65 20 69 74 20 62 | 79 20 63 68 61 6e 67 69 |nge it b|y changi|
|00000530| 6e 67 20 74 68 65 20 6c | 69 6e 65 73 0a 23 64 65 |ng the l|ines.#de|
|00000540| 66 69 6e 65 20 4d 41 52 | 4b 0a 61 6e 64 0a 23 64 |fine MAR|K.and.#d|
|00000550| 65 66 69 6e 65 20 4d 41 | 52 4b 4c 45 4e 0a 74 6f |efine MA|RKLEN.to|
|00000560| 20 79 6f 75 72 20 6f 77 | 6e 20 76 61 6c 75 65 73 | your ow|n values|
|00000570| 2e 0a 0a 49 27 64 20 62 | 65 20 69 6e 74 65 72 65 |...I'd b|e intere|
|00000580| 73 74 65 64 20 69 6e 20 | 68 65 61 72 69 6e 67 20 |sted in |hearing |
|00000590| 77 68 61 74 20 70 65 6f | 70 6c 65 20 68 61 76 65 |what peo|ple have|
|000005a0| 20 74 6f 20 73 61 79 20 | 61 6e 64 20 77 68 61 74 | to say |and what|
|000005b0| 20 74 68 65 79 20 75 73 | 65 20 27 62 75 67 27 0a | they us|e 'bug'.|
|000005c0| 66 6f 72 2e 20 20 49 20 | 68 6f 70 65 20 49 20 68 |for. I |hope I h|
|000005d0| 61 76 65 6e 27 74 20 72 | 65 2d 69 6e 76 65 6e 74 |aven't r|e-invent|
|000005e0| 65 64 20 74 68 65 20 77 | 68 65 65 6c 2e 20 20 42 |ed the w|heel. B|
|000005f0| 75 67 73 2f 43 6f 6d 6d | 65 6e 74 73 2f 51 75 65 |ugs/Comm|ents/Que|
|00000600| 73 74 69 6f 6e 73 2f 48 | 61 74 65 20 0a 4d 61 69 |stions/H|ate .Mai|
|00000610| 6c 20 74 6f 20 6d 65 2c | 0a 0a 4d 61 74 74 68 65 |l to me,|..Matthe|
|00000620| 77 20 4d 65 72 7a 62 61 | 63 68 65 72 09 41 52 50 |w Merzba|cher.ARP|
|00000630| 41 3a 09 6d 61 74 74 68 | 65 77 40 43 53 2e 55 43 |A:.matth|ew@CS.UC|
|00000640| 4c 41 2e 45 44 55 0a 09 | 20 20 09 09 55 55 43 50 |LA.EDU..| ..UUCP|
|00000650| 3a 09 2e 2e 2e 21 7b 75 | 75 6e 65 74 7c 72 75 74 |:....!{u|unet|rut|
|00000660| 67 65 72 73 7c 75 63 62 | 76 61 78 7d 21 63 73 2e |gers|ucb|vax}!cs.|
|00000670| 75 63 6c 61 2e 65 64 75 | 21 6d 61 74 74 68 65 77 |ucla.edu|!matthew|
|00000680| 0a 53 48 41 52 5f 45 4f | 46 0a 66 69 20 23 20 65 |.SHAR_EO|F.fi # e|
|00000690| 6e 64 20 6f 66 20 6f 76 | 65 72 77 72 69 74 69 6e |nd of ov|erwritin|
|000006a0| 67 20 63 68 65 63 6b 0a | 69 66 20 74 65 73 74 20 |g check.|if test |
|000006b0| 2d 66 20 27 62 75 67 2e | 31 27 0a 74 68 65 6e 0a |-f 'bug.|1'.then.|
|000006c0| 09 65 63 68 6f 20 73 68 | 61 72 3a 20 77 69 6c 6c |.echo sh|ar: will|
|000006d0| 20 6e 6f 74 20 6f 76 65 | 72 2d 77 72 69 74 65 20 | not ove|r-write |
|000006e0| 65 78 69 73 74 69 6e 67 | 20 66 69 6c 65 20 22 27 |existing| file "'|
|000006f0| 62 75 67 2e 31 27 22 0a | 65 6c 73 65 0a 63 61 74 |bug.1'".|else.cat|
|00000700| 20 3c 3c 20 5c 53 48 41 | 52 5f 45 4f 46 20 3e 20 | << \SHA|R_EOF > |
|00000710| 27 62 75 67 2e 31 27 0a | 2e 54 48 20 42 55 47 20 |'bug.1'.|.TH BUG |
|00000720| 31 0a 5c 22 20 43 6f 70 | 79 72 69 67 68 74 20 28 |1.\" Cop|yright (|
|00000730| 43 29 20 31 39 38 39 20 | 62 79 20 4d 61 74 74 68 |C) 1989 |by Matth|
|00000740| 65 77 20 4d 65 72 7a 62 | 61 63 68 65 72 2e 20 20 |ew Merzb|acher. |
|00000750| 41 6c 6c 20 52 69 67 68 | 74 73 20 52 65 73 65 72 |All Righ|ts Reser|
|00000760| 76 65 64 2e 0a 2e 53 48 | 20 4e 41 4d 45 0a 62 75 |ved...SH| NAME.bu|
|00000770| 67 20 5c 2d 20 6c 69 73 | 74 65 6e 20 61 6e 64 20 |g \- lis|ten and |
|00000780| 74 72 61 6e 73 63 72 69 | 62 65 20 63 6f 6d 6d 75 |transcri|be commu|
|00000790| 6e 69 63 61 74 69 6f 6e | 20 6f 6e 20 61 20 73 6f |nication| on a so|
|000007a0| 63 6b 65 74 0a 2e 53 48 | 20 53 59 4e 4f 50 53 49 |cket..SH| SYNOPSI|
|000007b0| 53 0a 2e 42 20 62 75 67 | 0a 2e 6e 68 0a 69 6e 70 |S..B bug|..nh.inp|
|000007c0| 75 74 5f 70 6f 72 74 20 | 6f 75 74 70 75 74 5f 70 |ut_port |output_p|
|000007d0| 6f 72 74 20 6d 61 63 68 | 69 6e 65 20 63 6c 69 65 |ort mach|ine clie|
|000007e0| 6e 74 5f 66 69 6c 65 20 | 73 65 72 76 65 72 5f 66 |nt_file |server_f|
|000007f0| 69 6c 65 0a 2e 68 79 0a | 2e 53 48 20 44 45 53 43 |ile..hy.|.SH DESC|
|00000800| 52 49 50 54 49 4f 4e 0a | 2e 49 20 62 75 67 0a 69 |RIPTION.|.I bug.i|
|00000810| 73 20 75 73 65 64 20 74 | 6f 20 6c 69 73 74 65 6e |s used t|o listen|
|00000820| 20 6f 6e 20 61 20 73 70 | 65 63 69 66 69 65 64 20 | on a sp|ecified |
|00000830| 5c 66 49 69 6e 70 75 74 | 5f 70 6f 72 74 5c 66 52 |\fIinput|_port\fR|
|00000840| 20 61 6e 64 20 77 72 69 | 74 65 20 61 6e 20 65 78 | and wri|te an ex|
|00000850| 61 63 74 0a 64 75 70 6c | 69 63 61 74 65 20 6f 75 |act.dupl|icate ou|
|00000860| 74 20 74 6f 20 74 68 65 | 20 5c 66 49 6f 75 74 70 |t to the| \fIoutp|
|00000870| 75 74 5f 70 6f 72 74 5c | 66 52 20 6f 6e 20 61 20 |ut_port\|fR on a |
|00000880| 73 70 65 63 69 66 69 65 | 64 20 5c 66 49 6d 61 63 |specifie|d \fImac|
|00000890| 68 69 6e 65 5c 66 52 2e | 20 20 49 74 20 0a 61 6c |hine\fR.| It .al|
|000008a0| 73 6f 20 77 72 69 74 65 | 73 20 61 20 74 72 61 6e |so write|s a tran|
|000008b0| 73 63 72 69 70 74 20 6f | 66 20 65 76 65 72 79 74 |script o|f everyt|
|000008c0| 68 69 6e 67 20 74 68 61 | 74 20 69 73 20 73 61 69 |hing tha|t is sai|
|000008d0| 64 20 6f 6e 20 65 69 74 | 68 65 72 20 70 6f 72 74 |d on eit|her port|
|000008e0| 0a 74 6f 20 73 65 70 65 | 72 61 74 65 20 66 69 6c |.to sepe|rate fil|
|000008f0| 65 73 2e 20 20 45 61 63 | 68 20 70 69 65 63 65 20 |es. Eac|h piece |
|00000900| 6f 66 20 63 6f 6d 6d 75 | 6e 69 63 61 74 69 6f 6e |of commu|nication|
|00000910| 20 69 73 20 73 65 70 65 | 72 61 74 65 64 20 62 79 | is sepe|rated by|
|00000920| 20 61 20 4d 41 52 4b 2c | 20 77 68 69 63 68 0a 69 | a MARK,| which.i|
|00000930| 73 20 23 64 65 66 69 6e | 65 64 20 69 6e 20 74 68 |s #defin|ed in th|
|00000940| 65 20 63 6f 64 65 20 61 | 73 20 22 3c 4d 41 52 4b |e code a|s "<MARK|
|00000950| 3e 22 2e 0a 2e 50 50 0a | 54 68 65 20 6e 61 6d 69 |>"...PP.|The nami|
|00000960| 6e 67 20 73 63 68 65 6d | 65 20 66 6f 72 20 74 68 |ng schem|e for th|
|00000970| 65 20 6f 75 74 70 75 74 | 20 66 69 6c 65 73 20 69 |e output| files i|
|00000980| 73 20 5c 66 49 63 6c 69 | 65 6e 74 5f 66 69 6c 65 |s \fIcli|ent_file|
|00000990| 5c 66 52 20 28 66 6f 72 | 20 63 6f 6d 6d 75 6e 69 |\fR (for| communi|
|000009a0| 63 61 74 69 6f 6e 0a 72 | 65 63 65 69 76 65 64 20 |cation.r|eceived |
|000009b0| 66 72 6f 6d 20 74 68 65 | 20 5c 66 49 69 6e 70 75 |from the| \fIinpu|
|000009c0| 74 5f 70 6f 72 74 5c 66 | 52 29 20 6f 72 20 5c 66 |t_port\f|R) or \f|
|000009d0| 49 73 65 72 76 65 72 5f | 66 69 6c 65 5c 66 52 20 |Iserver_|file\fR |
|000009e0| 28 66 6f 72 20 63 6f 6d | 6d 75 6e 69 63 61 74 69 |(for com|municati|
|000009f0| 6f 6e 20 0a 72 65 63 65 | 69 76 65 64 20 66 72 6f |on .rece|ived fro|
|00000a00| 6d 20 74 68 65 20 5c 66 | 49 6f 75 74 70 75 74 5f |m the \f|Ioutput_|
|00000a10| 70 6f 72 74 5c 66 52 29 | 20 66 6f 6c 6c 6f 77 65 |port\fR)| followe|
|00000a20| 64 20 62 79 20 61 20 70 | 65 72 69 6f 64 20 28 27 |d by a p|eriod ('|
|00000a30| 2e 27 29 20 66 6f 6c 6c | 6f 77 65 64 20 62 79 20 |.') foll|owed by |
|00000a40| 0a 74 68 65 20 70 72 6f | 63 65 73 73 20 69 64 20 |.the pro|cess id |
|00000a50| 6f 66 20 74 68 65 20 62 | 75 67 20 70 72 6f 67 72 |of the b|ug progr|
|00000a60| 61 6d 20 66 6f 6c 6c 6f | 77 65 64 20 62 79 20 61 |am follo|wed by a|
|00000a70| 20 70 65 72 69 6f 64 20 | 28 27 2e 27 29 20 66 6f | period |('.') fo|
|00000a80| 6c 6c 6f 77 65 64 20 62 | 79 20 74 68 65 20 0a 70 |llowed b|y the .p|
|00000a90| 72 6f 63 65 73 73 20 69 | 64 20 6f 66 20 74 68 65 |rocess i|d of the|
|00000aa0| 20 63 68 69 6c 64 20 6f | 66 20 62 75 67 20 77 68 | child o|f bug wh|
|00000ab0| 69 63 68 20 61 63 74 75 | 61 6c 6c 79 20 64 6f 65 |ich actu|ally doe|
|00000ac0| 73 20 74 68 65 20 6d 6f | 6e 69 74 6f 72 69 6e 67 |s the mo|nitoring|
|00000ad0| 2e 20 20 54 68 75 73 2c | 20 66 6f 72 20 0a 65 76 |. Thus,| for .ev|
|00000ae0| 65 72 79 20 63 6f 6e 6e | 65 63 74 69 6f 6e 20 6d |ery conn|ection m|
|00000af0| 61 64 65 20 74 6f 20 74 | 68 65 20 69 6e 70 75 74 |ade to t|he input|
|00000b00| 5f 70 6f 72 74 2c 20 74 | 68 65 72 65 20 77 69 6c |_port, t|here wil|
|00000b10| 6c 20 62 65 20 74 77 6f | 20 28 75 6e 69 71 75 65 |l be two| (unique|
|00000b20| 29 20 66 69 6c 65 73 20 | 0a 63 72 65 61 74 65 64 |) files |.created|
|00000b30| 2e 0a 2e 50 50 0a 54 68 | 65 20 6f 75 74 70 75 74 |...PP.Th|e output|
|00000b40| 20 66 69 6c 65 73 20 61 | 72 65 20 70 72 6f 62 61 | files a|re proba|
|00000b50| 62 6c 79 20 62 65 73 74 | 20 72 65 61 64 20 62 79 |bly best| read by|
|00000b60| 20 75 73 69 6e 67 20 5c | 66 49 6f 64 5c 66 52 28 | using \|fIod\fR(|
|00000b70| 31 29 20 77 69 74 68 20 | 74 68 65 20 22 2d 63 22 |1) with |the "-c"|
|00000b80| 20 0a 6f 72 20 22 2d 63 | 78 22 20 6f 70 74 69 6f | .or "-c|x" optio|
|00000b90| 6e 73 2e 0a 2e 53 48 20 | 45 58 41 4d 50 4c 45 0a |ns...SH |EXAMPLE.|
|00000ba0| 5c 66 49 62 75 67 5c 66 | 52 20 33 30 30 30 20 32 |\fIbug\f|R 3000 2|
|00000bb0| 39 39 39 20 6d 6f 6f 73 | 65 62 72 65 61 74 68 20 |999 moos|ebreath |
|00000bc0| 63 6c 20 73 65 0a 2e 50 | 50 0a 54 68 69 73 20 69 |cl se..P|P.This i|
|00000bd0| 6e 76 6f 63 61 74 69 6f | 6e 20 77 69 6c 6c 20 63 |nvocatio|n will c|
|00000be0| 72 65 61 74 65 2c 20 66 | 6f 72 20 65 76 65 72 79 |reate, f|or every|
|00000bf0| 20 63 6f 6e 6e 65 63 74 | 69 6f 6e 20 74 6f 20 70 | connect|ion to p|
|00000c00| 6f 72 74 20 33 30 30 30 | 20 6f 6e 20 74 68 65 20 |ort 3000| on the |
|00000c10| 63 75 72 72 65 6e 74 20 | 0a 6d 61 63 68 69 6e 65 |current |.machine|
|00000c20| 2c 20 74 77 6f 20 66 69 | 6c 65 73 20 28 63 6c 2e |, two fi|les (cl.|
|00000c30| 70 69 64 2e 63 70 69 64 | 20 61 6e 64 20 73 65 2e |pid.cpid| and se.|
|00000c40| 70 69 64 2e 63 70 69 64 | 29 2e 20 20 45 76 65 72 |pid.cpid|). Ever|
|00000c50| 79 20 63 6f 6d 6d 75 6e | 69 63 61 74 69 6f 6e 20 |y commun|ication |
|00000c60| 74 6f 20 70 6f 72 74 0a | 33 30 30 30 20 69 73 20 |to port.|3000 is |
|00000c70| 72 65 70 65 61 74 65 64 | 20 76 65 72 62 61 74 69 |repeated| verbati|
|00000c80| 6d 20 74 6f 20 70 6f 72 | 74 20 32 39 39 39 20 6f |m to por|t 2999 o|
|00000c90| 6e 20 6d 61 63 68 69 6e | 65 20 22 6d 6f 6f 73 65 |n machin|e "moose|
|00000ca0| 62 72 65 61 74 68 22 20 | 61 6e 64 20 77 72 69 74 |breath" |and writ|
|00000cb0| 74 65 6e 20 74 6f 0a 74 | 68 65 20 66 69 72 73 74 |ten to.t|he first|
|00000cc0| 20 66 69 6c 65 2e 20 20 | 41 6c 6c 20 72 65 73 70 | file. |All resp|
|00000cd0| 6f 6e 73 65 73 20 61 72 | 65 20 77 72 69 74 74 65 |onses ar|e writte|
|00000ce0| 6e 20 74 6f 20 74 68 65 | 20 73 65 63 6f 6e 64 20 |n to the| second |
|00000cf0| 66 69 6c 65 2e 0a 2e 53 | 48 20 46 49 4c 45 53 0a |file...S|H FILES.|
|00000d00| 2e 62 72 0a 63 72 65 61 | 74 65 73 20 66 69 6c 65 |.br.crea|tes file|
|00000d10| 73 20 62 61 73 65 64 20 | 6f 6e 20 5c 66 49 63 6c |s based |on \fIcl|
|00000d20| 69 65 6e 74 5f 66 69 6c | 65 5c 66 52 20 61 6e 64 |ient_fil|e\fR and|
|00000d30| 20 5c 66 49 73 65 72 76 | 65 72 5f 66 69 6c 65 5c | \fIserv|er_file\|
|00000d40| 66 52 0a 2e 53 48 20 22 | 53 45 45 20 41 4c 53 4f |fR..SH "|SEE ALSO|
|00000d50| 22 0a 6f 64 28 31 29 2c | 20 73 6f 63 6b 65 74 28 |".od(1),| socket(|
|00000d60| 32 29 20 5b 61 6e 64 20 | 66 72 69 65 6e 64 73 5d |2) [and |friends]|
|00000d70| 2c 20 66 6f 72 6b 28 32 | 29 2e 0a 2e 53 48 20 41 |, fork(2|)...SH A|
|00000d80| 55 54 48 4f 52 0a 4d 61 | 74 74 68 65 77 20 4d 65 |UTHOR.Ma|tthew Me|
|00000d90| 72 7a 62 61 63 68 65 72 | 2c 20 62 75 67 73 2f 63 |rzbacher|, bugs/c|
|00000da0| 6f 6d 6d 65 6e 74 73 20 | 2d 20 6d 61 74 74 68 65 |omments |- matthe|
|00000db0| 77 40 63 73 2e 75 63 6c | 61 2e 65 64 75 0a 2e 53 |w@cs.ucl|a.edu..S|
|00000dc0| 48 20 42 55 47 53 0a 2e | 50 50 0a 47 6f 6f 64 6e |H BUGS..|PP.Goodn|
|00000dd0| 65 73 73 20 6b 6e 6f 77 | 73 20 77 68 61 74 20 73 |ess know|s what s|
|00000de0| 79 73 74 65 6d 73 20 74 | 68 69 73 20 77 69 6c 6c |ystems t|his will|
|00000df0| 20 61 63 74 75 61 6c 6c | 79 20 72 75 6e 20 6f 6e | actuall|y run on|
|00000e00| 2e 20 20 41 6e 79 20 42 | 53 44 20 6f 72 20 0a 42 |. Any B|SD or .B|
|00000e10| 53 44 2d 64 65 72 69 76 | 65 64 20 73 79 73 74 65 |SD-deriv|ed syste|
|00000e20| 6d 20 53 48 4f 55 4c 44 | 20 77 6f 72 6b 2e 0a 0a |m SHOULD| work...|
|00000e30| 54 68 65 72 65 20 73 68 | 6f 75 6c 64 20 62 65 20 |There sh|ould be |
|00000e40| 61 6e 20 6f 70 74 69 6f | 6e 20 74 6f 20 63 68 61 |an optio|n to cha|
|00000e50| 6e 67 65 20 74 68 65 20 | 4d 41 52 4b 2e 0a 53 48 |nge the |MARK..SH|
|00000e60| 41 52 5f 45 4f 46 0a 66 | 69 20 23 20 65 6e 64 20 |AR_EOF.f|i # end |
|00000e70| 6f 66 20 6f 76 65 72 77 | 72 69 74 69 6e 67 20 63 |of overw|riting c|
|00000e80| 68 65 63 6b 0a 69 66 20 | 74 65 73 74 20 2d 66 20 |heck.if |test -f |
|00000e90| 27 62 75 67 2e 63 27 0a | 74 68 65 6e 0a 09 65 63 |'bug.c'.|then..ec|
|00000ea0| 68 6f 20 73 68 61 72 3a | 20 77 69 6c 6c 20 6e 6f |ho shar:| will no|
|00000eb0| 74 20 6f 76 65 72 2d 77 | 72 69 74 65 20 65 78 69 |t over-w|rite exi|
|00000ec0| 73 74 69 6e 67 20 66 69 | 6c 65 20 22 27 62 75 67 |sting fi|le "'bug|
|00000ed0| 2e 63 27 22 0a 65 6c 73 | 65 0a 63 61 74 20 3c 3c |.c'".els|e.cat <<|
|00000ee0| 20 5c 53 48 41 52 5f 45 | 4f 46 20 3e 20 27 62 75 | \SHAR_E|OF > 'bu|
|00000ef0| 67 2e 63 27 0a 2f 2a 20 | 43 6f 70 79 72 69 67 68 |g.c'./* |Copyrigh|
|00000f00| 74 20 28 43 29 20 31 39 | 38 39 20 62 79 20 4d 61 |t (C) 19|89 by Ma|
|00000f10| 74 74 68 65 77 20 4d 65 | 72 7a 62 61 63 68 65 72 |tthew Me|rzbacher|
|00000f20| 2e 0a 20 20 20 41 6c 6c | 20 52 69 67 68 74 73 20 |.. All| Rights |
|00000f30| 52 65 73 65 72 76 65 64 | 2e 0a 20 20 20 42 75 67 |Reserved|.. Bug|
|00000f40| 20 69 73 20 70 72 6f 76 | 69 64 65 64 20 61 73 20 | is prov|ided as |
|00000f50| 69 73 2c 20 77 69 74 68 | 6f 75 74 20 65 78 70 72 |is, with|out expr|
|00000f60| 65 73 73 20 6f 72 20 69 | 6d 70 6c 69 65 64 20 77 |ess or i|mplied w|
|00000f70| 61 72 72 61 6e 74 79 2e | 20 20 49 6e 20 6e 6f 20 |arranty.| In no |
|00000f80| 65 76 65 6e 74 0a 20 20 | 20 73 68 61 6c 6c 20 4d |event. | shall M|
|00000f90| 61 74 74 68 65 77 20 4d | 65 72 7a 62 61 63 68 65 |atthew M|erzbache|
|00000fa0| 72 20 62 65 63 6f 6d 65 | 20 6c 69 61 62 6c 65 20 |r become| liable |
|00000fb0| 66 6f 72 20 61 6e 79 20 | 6c 6f 73 73 20 6f 72 20 |for any |loss or |
|00000fc0| 64 61 6d 61 67 65 73 2c | 20 63 6f 6e 73 65 71 75 |damages,| consequ|
|00000fd0| 65 6e 74 69 61 6c 0a 20 | 20 20 6f 72 20 6f 74 68 |ential. | or oth|
|00000fe0| 65 72 77 69 73 65 2c 20 | 61 72 69 73 69 6e 67 20 |erwise, |arising |
|00000ff0| 66 72 6f 6d 20 74 68 65 | 20 75 73 65 20 6f 72 20 |from the| use or |
|00001000| 70 6f 73 73 65 73 73 69 | 6f 6e 20 6f 66 20 74 68 |possessi|on of th|
|00001010| 69 73 20 73 6f 66 74 77 | 61 72 65 2e 0a 2a 2f 0a |is softw|are..*/.|
|00001020| 0a 23 69 6e 63 6c 75 64 | 65 20 3c 73 79 73 2f 74 |.#includ|e <sys/t|
|00001030| 79 70 65 73 2e 68 3e 0a | 23 69 6e 63 6c 75 64 65 |ypes.h>.|#include|
|00001040| 20 3c 73 79 73 2f 73 6f | 63 6b 65 74 2e 68 3e 0a | <sys/so|cket.h>.|
|00001050| 23 69 6e 63 6c 75 64 65 | 20 3c 6e 65 74 69 6e 65 |#include| <netine|
|00001060| 74 2f 69 6e 2e 68 3e 0a | 23 69 6e 63 6c 75 64 65 |t/in.h>.|#include|
|00001070| 20 3c 6e 65 74 64 62 2e | 68 3e 0a 23 69 6e 63 6c | <netdb.|h>.#incl|
|00001080| 75 64 65 20 3c 73 74 64 | 69 6f 2e 68 3e 0a 23 69 |ude <std|io.h>.#i|
|00001090| 6e 63 6c 75 64 65 20 3c | 66 63 6e 74 6c 2e 68 3e |nclude <|fcntl.h>|
|000010a0| 0a 0a 23 64 65 66 69 6e | 65 20 4d 41 52 4b 20 22 |..#defin|e MARK "|
|000010b0| 3c 4d 41 52 4b 3e 22 0a | 23 64 65 66 69 6e 65 20 |<MARK>".|#define |
|000010c0| 4d 41 52 4b 4c 45 4e 20 | 36 0a 0a 2f 2a 0a 20 2a |MARKLEN |6../*. *|
|000010d0| 20 42 72 69 65 66 20 44 | 65 73 63 72 69 70 74 69 | Brief D|escripti|
|000010e0| 6f 6e 3a 0a 20 2a 20 42 | 75 67 20 69 73 20 75 73 |on:. * B|ug is us|
|000010f0| 65 64 20 74 6f 20 74 61 | 70 20 61 20 73 74 72 65 |ed to ta|p a stre|
|00001100| 61 6d 20 73 6f 63 6b 65 | 74 2e 20 20 49 74 20 69 |am socke|t. It i|
|00001110| 73 20 75 73 65 66 75 6c | 20 66 6f 72 20 74 72 61 |s useful| for tra|
|00001120| 63 69 6e 67 20 63 6f 6d | 6d 75 6e 69 63 61 74 69 |cing com|municati|
|00001130| 6f 6e 20 0a 20 2a 20 62 | 65 74 77 65 65 6e 20 61 |on . * b|etween a|
|00001140| 20 73 65 72 76 65 72 20 | 61 6e 64 20 69 74 73 20 | server |and its |
|00001150| 63 6c 69 65 6e 74 73 2e | 20 20 54 68 65 20 63 6f |clients.| The co|
|00001160| 6d 6d 75 6e 69 63 61 74 | 69 6f 6e 20 62 65 74 77 |mmunicat|ion betw|
|00001170| 65 65 6e 20 73 65 72 76 | 65 72 20 61 6e 64 0a 20 |een serv|er and. |
|00001180| 2a 20 63 6c 69 65 6e 74 | 20 69 73 20 6d 61 69 6e |* client| is main|
|00001190| 74 61 69 6e 65 64 20 77 | 68 69 6c 65 20 74 72 61 |tained w|hile tra|
|000011a0| 6e 73 63 72 69 70 74 73 | 20 6f 66 20 61 6c 6c 20 |nscripts| of all |
|000011b0| 63 6f 6d 6d 75 6e 69 63 | 61 74 69 6f 6e 20 6c 69 |communic|ation li|
|000011c0| 6e 65 73 20 61 72 65 20 | 74 61 6b 65 6e 2e 0a 20 |nes are |taken.. |
|000011d0| 2a 20 49 74 20 68 61 73 | 20 73 69 78 20 72 65 71 |* It has| six req|
|000011e0| 75 69 72 65 64 20 28 61 | 6e 64 20 6e 6f 20 6f 70 |uired (a|nd no op|
|000011f0| 74 69 6f 6e 61 6c 29 20 | 61 72 67 75 6d 65 6e 74 |tional) |argument|
|00001200| 73 2e 20 20 0a 20 2a 0a | 20 2a 20 55 73 61 67 65 |s. . *.| * Usage|
|00001210| 3a 0a 20 2a 20 62 75 67 | 20 3c 69 6e 20 70 6f 72 |:. * bug| <in por|
|00001220| 74 3e 20 3c 6f 75 74 20 | 70 6f 72 74 3e 20 3c 6d |t> <out |port> <m|
|00001230| 61 63 68 69 6e 65 3e 20 | 3c 63 6c 69 65 6e 74 20 |achine> |<client |
|00001240| 66 69 6c 65 3e 20 3c 73 | 65 72 76 65 72 20 66 69 |file> <s|erver fi|
|00001250| 6c 65 3e 0a 20 2a 0a 20 | 2a 20 3c 69 6e 20 70 6f |le>. *. |* <in po|
|00001260| 72 74 3e 20 20 20 20 20 | 2d 20 74 68 65 20 70 6f |rt> |- the po|
|00001270| 72 74 20 28 6f 6e 20 74 | 68 65 20 6d 61 63 68 69 |rt (on t|he machi|
|00001280| 6e 65 20 6f 6e 20 77 68 | 69 63 68 20 62 75 67 20 |ne on wh|ich bug |
|00001290| 72 75 6e 73 29 20 74 6f | 20 77 68 69 63 68 20 74 |runs) to| which t|
|000012a0| 6f 0a 20 2a 09 09 09 09 | 20 20 20 63 6c 69 65 6e |o. *....| clien|
|000012b0| 74 73 20 77 69 6c 6c 20 | 63 6f 6e 6e 65 63 74 20 |ts will |connect |
|000012c0| 28 74 68 65 20 70 73 65 | 75 64 6f 2d 70 6f 72 74 |(the pse|udo-port|
|000012d0| 29 0a 20 2a 20 3c 6f 75 | 74 20 70 6f 72 74 3e 20 |). * <ou|t port> |
|000012e0| 20 20 20 2d 20 74 68 65 | 20 74 72 75 65 20 73 65 | - the| true se|
|000012f0| 72 76 65 72 20 70 6f 72 | 74 0a 20 2a 20 3c 6d 61 |rver por|t. * <ma|
|00001300| 63 68 69 6e 65 3e 20 20 | 20 20 20 2d 20 74 68 65 |chine> | - the|
|00001310| 20 73 65 72 76 65 72 20 | 6d 61 63 68 69 6e 65 0a | server |machine.|
|00001320| 20 2a 20 3c 63 6c 69 65 | 6e 74 20 66 69 6c 65 3e | * <clie|nt file>|
|00001330| 20 2d 20 74 72 61 6e 73 | 63 72 69 70 74 20 66 69 | - trans|cript fi|
|00001340| 6c 65 20 6f 66 20 77 68 | 61 74 20 65 61 63 68 20 |le of wh|at each |
|00001350| 63 6c 69 65 6e 74 20 73 | 61 79 73 0a 20 2a 20 3c |client s|ays. * <|
|00001360| 73 65 72 76 65 72 20 66 | 69 6c 65 3e 20 2d 20 74 |server f|ile> - t|
|00001370| 72 61 6e 73 63 72 69 70 | 74 20 66 69 6c 65 20 6f |ranscrip|t file o|
|00001380| 66 20 77 68 61 74 20 74 | 68 65 20 73 65 72 76 65 |f what t|he serve|
|00001390| 72 20 72 65 73 70 6f 6e | 64 73 0a 20 2a 0a 20 2a |r respon|ds. *. *|
|000013a0| 20 45 78 61 6d 70 6c 65 | 3a 20 0a 20 2a 20 53 75 | Example|: . * Su|
|000013b0| 70 70 6f 73 65 20 61 20 | 73 65 72 76 65 72 20 6c |ppose a |server l|
|000013c0| 69 73 74 65 6e 73 20 6f | 6e 20 70 6f 72 74 20 33 |istens o|n port 3|
|000013d0| 30 30 30 20 6f 66 20 6d | 61 63 68 69 6e 65 20 22 |000 of m|achine "|
|000013e0| 78 79 7a 22 2e 20 20 54 | 68 65 20 75 73 65 72 20 |xyz". T|he user |
|000013f0| 6d 75 73 74 20 0a 20 2a | 20 61 72 74 69 66 69 63 |must . *| artific|
|00001400| 69 61 6c 6c 79 20 6d 61 | 6b 65 20 74 68 65 20 63 |ially ma|ke the c|
|00001410| 6c 69 65 6e 74 73 20 74 | 61 6c 6b 20 74 6f 20 73 |lients t|alk to s|
|00001420| 6f 6d 65 20 6f 74 68 65 | 72 20 70 6f 72 74 20 28 |ome othe|r port (|
|00001430| 6f 6e 20 61 6e 79 20 6d | 61 63 68 69 6e 65 20 2d |on any m|achine -|
|00001440| 0a 20 2a 20 69 74 20 63 | 6f 75 6c 64 20 62 65 20 |. * it c|ould be |
|00001450| 74 68 65 20 73 65 72 76 | 65 72 20 6d 61 63 68 69 |the serv|er machi|
|00001460| 6e 65 2c 20 74 68 65 20 | 63 6c 69 65 6e 74 20 6d |ne, the |client m|
|00001470| 61 63 68 69 6e 65 2c 20 | 6f 72 20 61 20 74 68 69 |achine, |or a thi|
|00001480| 72 64 20 6d 61 63 68 69 | 6e 65 29 2e 0a 20 2a 20 |rd machi|ne).. * |
|00001490| 54 68 61 74 20 70 6f 72 | 74 20 69 73 20 63 61 6c |That por|t is cal|
|000014a0| 6c 65 64 20 74 68 65 20 | 70 73 65 75 64 6f 2d 70 |led the |pseudo-p|
|000014b0| 6f 72 74 2e 20 20 42 75 | 67 20 72 75 6e 73 20 6f |ort. Bu|g runs o|
|000014c0| 6e 20 74 68 65 20 6d 61 | 63 68 69 6e 65 20 6f 66 |n the ma|chine of|
|000014d0| 20 74 68 65 0a 20 2a 20 | 70 73 65 75 64 6f 2d 70 | the. * |pseudo-p|
|000014e0| 6f 72 74 2e 20 20 54 6f | 20 72 75 6e 20 69 74 2c |ort. To| run it,|
|000014f0| 20 74 79 70 65 3a 0a 20 | 2a 20 0a 20 2a 20 62 75 | type:. |* . * bu|
|00001500| 67 20 32 39 39 39 20 33 | 30 30 30 20 78 79 7a 20 |g 2999 3|000 xyz |
|00001510| 63 6c 69 65 6e 74 20 73 | 65 72 76 65 72 0a 20 2a |client s|erver. *|
|00001520| 0a 20 2a 20 54 68 69 73 | 20 61 73 73 75 6d 65 73 |. * This| assumes|
|00001530| 20 74 68 61 74 20 74 68 | 65 20 70 73 65 75 64 6f | that th|e pseudo|
|00001540| 2d 70 6f 72 74 20 69 73 | 20 32 39 39 39 2e 20 20 |-port is| 2999. |
|00001550| 54 68 65 20 6f 75 74 70 | 75 74 20 66 69 6c 65 73 |The outp|ut files|
|00001560| 20 77 69 6c 6c 20 61 6c | 6c 20 73 74 61 72 74 0a | will al|l start.|
|00001570| 20 2a 20 77 69 74 68 20 | 22 63 6c 69 65 6e 74 22 | * with |"client"|
|00001580| 20 6f 72 20 22 73 65 72 | 76 65 72 22 20 66 6f 6c | or "ser|ver" fol|
|00001590| 6c 6f 77 65 64 20 62 79 | 20 74 68 65 20 70 72 6f |lowed by| the pro|
|000015a0| 63 65 73 73 20 6e 75 6d | 62 65 72 20 6f 66 20 74 |cess num|ber of t|
|000015b0| 68 65 20 62 75 67 20 70 | 72 6f 63 65 73 73 0a 20 |he bug p|rocess. |
|000015c0| 2a 20 61 6e 64 20 74 68 | 65 20 70 72 6f 63 65 73 |* and th|e proces|
|000015d0| 73 20 6e 75 6d 62 65 72 | 20 6f 66 20 65 61 63 68 |s number| of each|
|000015e0| 20 73 65 70 65 72 61 74 | 65 20 6c 69 73 74 65 6e | seperat|e listen|
|000015f0| 69 6e 67 20 73 65 73 73 | 69 6f 6e 2e 20 20 54 68 |ing sess|ion. Th|
|00001600| 61 74 20 77 61 79 2c 20 | 79 6f 75 0a 20 2a 20 63 |at way, |you. * c|
|00001610| 61 6e 20 66 6f 6c 6c 6f | 77 20 74 68 65 20 63 6f |an follo|w the co|
|00001620| 6e 6e 65 63 74 69 6f 6e | 20 6f 72 64 65 72 2e 20 |nnection| order. |
|00001630| 20 54 79 70 69 63 61 6c | 6c 79 2c 20 74 68 65 20 | Typical|ly, the |
|00001640| 6f 75 74 70 75 74 20 66 | 69 6c 65 73 20 63 72 65 |output f|iles cre|
|00001650| 61 74 65 64 20 62 79 20 | 62 75 67 0a 20 2a 20 6d |ated by |bug. * m|
|00001660| 61 79 20 62 65 20 72 65 | 61 64 20 62 79 20 75 73 |ay be re|ad by us|
|00001670| 69 6e 67 20 27 6f 64 20 | 2d 63 27 2e 0a 20 2a 0a |ing 'od |-c'.. *.|
|00001680| 20 2a 2f 0a 0a 6d 61 69 | 6e 28 61 72 67 63 2c 20 | */..mai|n(argc, |
|00001690| 61 72 67 76 29 0a 69 6e | 74 20 61 72 67 63 3b 20 |argv).in|t argc; |
|000016a0| 63 68 61 72 20 2a 61 72 | 67 76 5b 5d 3b 0a 7b 0a |char *ar|gv[];.{.|
|000016b0| 20 20 20 20 73 74 72 75 | 63 74 20 73 6f 63 6b 61 | stru|ct socka|
|000016c0| 64 64 72 5f 69 6e 20 73 | 65 72 76 65 72 3b 0a 20 |ddr_in s|erver;. |
|000016d0| 20 20 20 73 74 72 75 63 | 74 20 68 6f 73 74 65 6e | struc|t hosten|
|000016e0| 74 20 2a 68 70 2c 20 2a | 67 65 74 68 6f 73 74 62 |t *hp, *|gethostb|
|000016f0| 79 6e 61 6d 65 28 29 3b | 0a 20 20 20 20 63 68 61 |yname();|. cha|
|00001700| 72 20 62 75 66 5b 31 30 | 32 34 5d 3b 0a 20 20 20 |r buf[10|24];. |
|00001710| 20 69 6e 74 20 72 76 61 | 6c 3b 0a 20 20 20 20 69 | int rva|l;. i|
|00001720| 6e 74 20 6f 75 74 66 69 | 6c 65 31 2c 20 6f 75 74 |nt outfi|le1, out|
|00001730| 66 69 6c 65 32 3b 0a 20 | 20 20 20 69 6e 74 20 69 |file2;. | int i|
|00001740| 6e 73 6f 63 6b 2c 20 6f | 75 74 73 6f 63 6b 2c 20 |nsock, o|utsock, |
|00001750| 6d 73 67 73 6f 63 6b 3b | 0a 20 20 20 20 69 6e 74 |msgsock;|. int|
|00001760| 20 69 6e 73 6f 63 6b 6e | 75 6d 2c 20 6f 75 74 73 | insockn|um, outs|
|00001770| 6f 63 6b 6e 75 6d 3b 0a | 20 20 20 20 66 64 5f 73 |ocknum;.| fd_s|
|00001780| 65 74 20 66 64 73 65 74 | 3b 0a 0a 0a 20 20 20 20 |et fdset|;... |
|00001790| 2f 2a 20 43 68 65 63 6b | 20 41 72 67 75 6d 65 6e |/* Check| Argumen|
|000017a0| 74 73 20 2a 2f 0a 0a 20 | 20 20 20 69 66 20 28 61 |ts */.. | if (a|
|000017b0| 72 67 63 20 3c 20 36 29 | 20 7b 0a 09 70 72 69 6e |rgc < 6)| {..prin|
|000017c0| 74 66 28 22 75 73 61 67 | 65 3a 20 25 73 20 3c 69 |tf("usag|e: %s <i|
|000017d0| 6e 20 70 6f 72 74 3e 20 | 3c 6f 75 74 20 70 6f 72 |n port> |<out por|
|000017e0| 74 3e 20 3c 6d 61 63 68 | 69 6e 65 3e 20 3c 63 6c |t> <mach|ine> <cl|
|000017f0| 69 65 6e 74 20 66 69 6c | 65 3e 20 3c 73 65 72 76 |ient fil|e> <serv|
|00001800| 65 72 20 66 69 6c 65 3e | 5c 6e 22 2c 61 72 67 76 |er file>|\n",argv|
|00001810| 5b 30 5d 29 3b 0a 09 65 | 78 69 74 28 31 29 3b 0a |[0]);..e|xit(1);.|
|00001820| 09 7d 0a 0a 20 20 20 20 | 69 6e 73 6f 63 6b 6e 75 |.}.. |insocknu|
|00001830| 6d 20 3d 20 61 74 6f 69 | 28 61 72 67 76 5b 31 5d |m = atoi|(argv[1]|
|00001840| 29 3b 0a 20 20 20 20 6f | 75 74 73 6f 63 6b 6e 75 |);. o|utsocknu|
|00001850| 6d 20 3d 20 61 74 6f 69 | 28 61 72 67 76 5b 32 5d |m = atoi|(argv[2]|
|00001860| 29 3b 0a 0a 0a 20 20 20 | 20 2f 2a 20 43 72 65 61 |);... | /* Crea|
|00001870| 74 65 20 6c 69 73 74 65 | 6e 69 6e 67 20 70 6f 73 |te liste|ning pos|
|00001880| 74 20 6f 6e 20 70 73 65 | 75 64 6f 2d 70 6f 72 74 |t on pse|udo-port|
|00001890| 20 2a 2f 0a 0a 20 20 20 | 20 69 6e 73 6f 63 6b 20 | */.. | insock |
|000018a0| 3d 20 73 6f 63 6b 65 74 | 28 41 46 5f 49 4e 45 54 |= socket|(AF_INET|
|000018b0| 2c 20 53 4f 43 4b 5f 53 | 54 52 45 41 4d 2c 20 30 |, SOCK_S|TREAM, 0|
|000018c0| 29 3b 0a 0a 20 20 20 20 | 69 66 20 28 69 6e 73 6f |);.. |if (inso|
|000018d0| 63 6b 20 3c 20 30 29 20 | 7b 0a 09 70 65 72 72 6f |ck < 0) |{..perro|
|000018e0| 72 28 22 6f 70 65 6e 69 | 6e 67 20 70 73 65 75 64 |r("openi|ng pseud|
|000018f0| 6f 2d 70 6f 72 74 20 73 | 74 72 65 61 6d 20 73 6f |o-port s|tream so|
|00001900| 63 6b 65 74 22 29 3b 0a | 09 65 78 69 74 28 31 29 |cket");.|.exit(1)|
|00001910| 3b 0a 09 7d 0a 0a 0a 20 | 20 20 20 2f 2a 20 4e 61 |;..}... | /* Na|
|00001920| 6d 65 20 73 6f 63 6b 65 | 74 20 75 73 69 6e 67 20 |me socke|t using |
|00001930| 75 73 65 72 20 73 75 70 | 70 6c 69 65 64 20 70 6f |user sup|plied po|
|00001940| 72 74 20 6e 75 6d 62 65 | 72 20 2a 2f 0a 0a 20 20 |rt numbe|r */.. |
|00001950| 20 20 73 65 72 76 65 72 | 2e 73 69 6e 5f 66 61 6d | server|.sin_fam|
|00001960| 69 6c 79 20 3d 20 41 46 | 5f 49 4e 45 54 3b 0a 20 |ily = AF|_INET;. |
|00001970| 20 20 20 73 65 72 76 65 | 72 2e 73 69 6e 5f 61 64 | serve|r.sin_ad|
|00001980| 64 72 2e 73 5f 61 64 64 | 72 20 3d 20 49 4e 41 44 |dr.s_add|r = INAD|
|00001990| 44 52 5f 41 4e 59 3b 0a | 20 20 20 20 73 65 72 76 |DR_ANY;.| serv|
|000019a0| 65 72 2e 73 69 6e 5f 70 | 6f 72 74 20 3d 20 69 6e |er.sin_p|ort = in|
|000019b0| 73 6f 63 6b 6e 75 6d 3b | 0a 0a 20 20 20 20 69 66 |socknum;|.. if|
|000019c0| 20 28 62 69 6e 64 28 69 | 6e 73 6f 63 6b 2c 20 26 | (bind(i|nsock, &|
|000019d0| 73 65 72 76 65 72 2c 20 | 73 69 7a 65 6f 66 28 73 |server, |sizeof(s|
|000019e0| 65 72 76 65 72 29 29 29 | 20 7b 0a 09 70 65 72 72 |erver)))| {..perr|
|000019f0| 6f 72 28 22 62 69 6e 64 | 69 6e 67 20 70 73 65 75 |or("bind|ing pseu|
|00001a00| 64 6f 2d 70 6f 72 74 20 | 73 74 72 65 61 6d 20 73 |do-port |stream s|
|00001a10| 6f 63 6b 65 74 22 29 3b | 0a 09 65 78 69 74 28 31 |ocket");|..exit(1|
|00001a20| 29 3b 0a 09 7d 0a 0a 0a | 20 20 20 20 2f 2a 20 53 |);..}...| /* S|
|00001a30| 74 61 72 74 20 61 63 63 | 65 70 74 69 6e 67 20 63 |tart acc|epting c|
|00001a40| 6f 6e 6e 65 63 74 69 6f | 6e 73 20 2a 2f 0a 0a 20 |onnectio|ns */.. |
|00001a50| 20 20 20 6c 69 73 74 65 | 6e 28 69 6e 73 6f 63 6b | liste|n(insock|
|00001a60| 2c 20 53 4f 4d 41 58 43 | 4f 4e 4e 29 3b 0a 0a 0a |, SOMAXC|ONN);...|
|00001a70| 20 20 20 20 2f 2a 20 45 | 76 65 72 79 20 63 6f 6e | /* E|very con|
|00001a80| 6e 65 63 74 69 6f 6e 20 | 73 70 61 77 6e 73 20 61 |nection |spawns a|
|00001a90| 20 63 68 69 6c 64 20 74 | 6f 20 68 61 6e 64 6c 65 | child t|o handle|
|00001aa0| 20 74 68 65 20 63 6f 6d | 6d 75 6e 69 63 61 74 69 | the com|municati|
|00001ab0| 6f 6e 20 2a 2f 0a 0a 20 | 20 20 20 64 6f 20 7b 0a |on */.. | do {.|
|00001ac0| 09 6d 73 67 73 6f 63 6b | 20 3d 20 61 63 63 65 70 |.msgsock| = accep|
|00001ad0| 74 28 69 6e 73 6f 63 6b | 2c 20 30 2c 20 30 29 3b |t(insock|, 0, 0);|
|00001ae0| 0a 09 69 66 20 28 6d 73 | 67 73 6f 63 6b 20 3d 3d |..if (ms|gsock ==|
|00001af0| 20 2d 31 29 0a 09 09 70 | 65 72 72 6f 72 28 22 61 | -1)...p|error("a|
|00001b00| 63 63 65 70 74 22 29 3b | 0a 09 7d 20 77 68 69 6c |ccept");|..} whil|
|00001b10| 65 20 28 66 6f 72 6b 28 | 29 20 21 3d 20 30 29 3b |e (fork(|) != 0);|
|00001b20| 0a 0a 0a 20 20 20 20 2f | 2a 20 43 6c 6f 73 65 20 |... /|* Close |
|00001b30| 6c 69 73 74 65 6e 69 6e | 67 20 70 6f 73 74 20 2d |listenin|g post -|
|00001b40| 20 69 74 27 73 20 6e 6f | 77 20 63 61 6c 6c 65 64 | it's no|w called|
|00001b50| 20 22 6d 73 67 73 6f 63 | 6b 22 20 2a 2f 0a 0a 20 | "msgsoc|k" */.. |
|00001b60| 20 20 20 63 6c 6f 73 65 | 28 69 6e 73 6f 63 6b 29 | close|(insock)|
|00001b70| 3b 0a 0a 0a 20 20 20 20 | 2f 2a 20 43 72 65 61 74 |;... |/* Creat|
|00001b80| 65 20 6f 75 74 70 75 74 | 20 73 6f 63 6b 65 74 20 |e output| socket |
|00001b90| 74 6f 20 73 65 72 76 65 | 72 20 2a 2f 0a 0a 20 20 |to serve|r */.. |
|00001ba0| 20 20 6f 75 74 73 6f 63 | 6b 20 3d 20 73 6f 63 6b | outsoc|k = sock|
|00001bb0| 65 74 28 41 46 5f 49 4e | 45 54 2c 20 53 4f 43 4b |et(AF_IN|ET, SOCK|
|00001bc0| 5f 53 54 52 45 41 4d 2c | 20 30 29 3b 0a 20 20 20 |_STREAM,| 0);. |
|00001bd0| 20 69 66 20 28 6f 75 74 | 73 6f 63 6b 20 3c 20 30 | if (out|sock < 0|
|00001be0| 29 20 7b 0a 09 70 65 72 | 72 6f 72 28 22 6f 70 65 |) {..per|ror("ope|
|00001bf0| 6e 69 6e 67 20 73 65 72 | 76 65 72 20 73 74 72 65 |ning ser|ver stre|
|00001c00| 61 6d 20 73 6f 63 6b 65 | 74 22 29 3b 0a 09 65 78 |am socke|t");..ex|
|00001c10| 69 74 28 31 29 3b 0a 09 | 7d 0a 0a 0a 20 20 20 20 |it(1);..|}... |
|00001c20| 2f 2a 20 43 6f 6e 6e 65 | 63 74 20 73 6f 63 6b 65 |/* Conne|ct socke|
|00001c30| 74 20 75 73 69 6e 67 20 | 6d 61 63 68 69 6e 65 20 |t using |machine |
|00001c40| 26 20 70 6f 72 74 20 73 | 70 65 63 69 66 69 65 64 |& port s|pecified|
|00001c50| 20 6f 6e 20 63 6f 6d 6d | 61 6e 64 20 6c 69 6e 65 | on comm|and line|
|00001c60| 2e 20 2a 2f 0a 0a 20 20 | 20 20 73 65 72 76 65 72 |. */.. | server|
|00001c70| 2e 73 69 6e 5f 66 61 6d | 69 6c 79 20 3d 20 41 46 |.sin_fam|ily = AF|
|00001c80| 5f 49 4e 45 54 3b 0a 20 | 20 20 20 68 70 20 3d 20 |_INET;. | hp = |
|00001c90| 67 65 74 68 6f 73 74 62 | 79 6e 61 6d 65 28 61 72 |gethostb|yname(ar|
|00001ca0| 67 76 5b 33 5d 29 3b 0a | 20 20 20 20 69 66 20 28 |gv[3]);.| if (|
|00001cb0| 68 70 20 3d 3d 20 30 29 | 20 7b 0a 09 66 70 72 69 |hp == 0)| {..fpri|
|00001cc0| 6e 74 66 28 73 74 64 65 | 72 72 2c 20 22 25 73 3a |ntf(stde|rr, "%s:|
|00001cd0| 20 75 6e 6b 6e 6f 77 6e | 20 6d 61 63 68 69 6e 65 | unknown| machine|
|00001ce0| 5c 6e 22 2c 20 61 72 67 | 76 5b 33 5d 29 3b 0a 09 |\n", arg|v[3]);..|
|00001cf0| 65 78 69 74 28 32 29 3b | 0a 09 7d 0a 0a 20 20 20 |exit(2);|..}.. |
|00001d00| 20 62 63 6f 70 79 28 68 | 70 2d 3e 68 5f 61 64 64 | bcopy(h|p->h_add|
|00001d10| 72 2c 20 26 73 65 72 76 | 65 72 2e 73 69 6e 5f 61 |r, &serv|er.sin_a|
|00001d20| 64 64 72 2c 20 68 70 2d | 3e 68 5f 6c 65 6e 67 74 |ddr, hp-|>h_lengt|
|00001d30| 68 29 3b 0a 20 20 20 20 | 73 65 72 76 65 72 2e 73 |h);. |server.s|
|00001d40| 69 6e 5f 70 6f 72 74 20 | 3d 20 68 74 6f 6e 73 28 |in_port |= htons(|
|00001d50| 6f 75 74 73 6f 63 6b 6e | 75 6d 29 3b 0a 0a 20 20 |outsockn|um);.. |
|00001d60| 20 20 69 66 20 28 63 6f | 6e 6e 65 63 74 28 6f 75 | if (co|nnect(ou|
|00001d70| 74 73 6f 63 6b 2c 20 26 | 73 65 72 76 65 72 2c 20 |tsock, &|server, |
|00001d80| 73 69 7a 65 6f 66 28 73 | 65 72 76 65 72 29 29 20 |sizeof(s|erver)) |
|00001d90| 3c 20 30 29 20 7b 0a 09 | 70 65 72 72 6f 72 28 22 |< 0) {..|perror("|
|00001da0| 63 6f 6e 6e 65 63 74 69 | 6e 67 20 73 65 72 76 65 |connecti|ng serve|
|00001db0| 72 20 73 74 72 65 61 6d | 20 73 6f 63 6b 65 74 22 |r stream| socket"|
|00001dc0| 29 3b 0a 09 65 78 69 74 | 28 31 29 3b 0a 09 7d 0a |);..exit|(1);..}.|
|00001dd0| 0a 0a 20 20 20 20 2f 2a | 20 4f 70 65 6e 20 74 68 |.. /*| Open th|
|00001de0| 65 20 6f 75 74 70 75 74 | 20 66 69 6c 65 73 20 2a |e output| files *|
|00001df0| 2f 0a 0a 20 20 20 20 73 | 70 72 69 6e 74 66 28 62 |/.. s|printf(b|
|00001e00| 75 66 2c 22 25 73 2e 25 | 64 2e 25 64 22 2c 61 72 |uf,"%s.%|d.%d",ar|
|00001e10| 67 76 5b 34 5d 2c 67 65 | 74 70 70 69 64 28 29 2c |gv[4],ge|tppid(),|
|00001e20| 67 65 74 70 69 64 28 29 | 29 3b 0a 20 20 20 20 69 |getpid()|);. i|
|00001e30| 66 20 28 28 6f 75 74 66 | 69 6c 65 31 20 3d 20 6f |f ((outf|ile1 = o|
|00001e40| 70 65 6e 28 62 75 66 2c | 20 4f 5f 54 52 55 4e 43 |pen(buf,| O_TRUNC|
|00001e50| 7c 4f 5f 57 52 4f 4e 4c | 59 7c 4f 5f 43 52 45 41 ||O_WRONL|Y|O_CREA|
|00001e60| 54 2c 20 30 36 34 34 29 | 29 20 3d 3d 20 2d 31 29 |T, 0644)|) == -1)|
|00001e70| 20 7b 0a 09 66 70 72 69 | 6e 74 66 28 73 74 64 65 | {..fpri|ntf(stde|
|00001e80| 72 72 2c 22 63 61 6e 6e | 6f 74 20 6f 70 65 6e 20 |rr,"cann|ot open |
|00001e90| 66 69 6c 65 3a 20 25 73 | 5c 6e 22 2c 62 75 66 29 |file: %s|\n",buf)|
|00001ea0| 3b 0a 09 65 78 69 74 28 | 31 29 3b 0a 09 7d 0a 0a |;..exit(|1);..}..|
|00001eb0| 20 20 20 20 73 70 72 69 | 6e 74 66 28 62 75 66 2c | spri|ntf(buf,|
|00001ec0| 22 25 73 2e 25 64 2e 25 | 64 22 2c 61 72 67 76 5b |"%s.%d.%|d",argv[|
|00001ed0| 35 5d 2c 67 65 74 70 70 | 69 64 28 29 2c 67 65 74 |5],getpp|id(),get|
|00001ee0| 70 69 64 28 29 29 3b 0a | 20 20 20 20 69 66 20 28 |pid());.| if (|
|00001ef0| 28 6f 75 74 66 69 6c 65 | 32 20 3d 20 6f 70 65 6e |(outfile|2 = open|
|00001f00| 28 62 75 66 2c 20 4f 5f | 54 52 55 4e 43 7c 4f 5f |(buf, O_|TRUNC|O_|
|00001f10| 57 52 4f 4e 4c 59 7c 4f | 5f 43 52 45 41 54 2c 20 |WRONLY|O|_CREAT, |
|00001f20| 30 36 34 34 29 29 20 3d | 3d 20 2d 31 29 20 7b 0a |0644)) =|= -1) {.|
|00001f30| 09 66 70 72 69 6e 74 66 | 28 73 74 64 65 72 72 2c |.fprintf|(stderr,|
|00001f40| 22 63 61 6e 6e 6f 74 20 | 6f 70 65 6e 20 66 69 6c |"cannot |open fil|
|00001f50| 65 3a 20 25 73 5c 6e 22 | 2c 62 75 66 29 3b 0a 09 |e: %s\n"|,buf);..|
|00001f60| 65 78 69 74 28 31 29 3b | 0a 09 7d 0a 0a 20 20 20 |exit(1);|..}.. |
|00001f70| 20 64 6f 20 7b 0a 09 0a | 09 2f 2a 20 66 69 6e 64 | do {...|./* find|
|00001f80| 20 6f 75 74 20 77 68 6f | 27 73 20 74 61 6c 6b 69 | out who|'s talki|
|00001f90| 6e 67 20 2a 2f 0a 0a 09 | 46 44 5f 5a 45 52 4f 28 |ng */...|FD_ZERO(|
|00001fa0| 26 66 64 73 65 74 29 3b | 0a 09 46 44 5f 53 45 54 |&fdset);|..FD_SET|
|00001fb0| 28 6d 73 67 73 6f 63 6b | 2c 20 26 66 64 73 65 74 |(msgsock|, &fdset|
|00001fc0| 29 3b 0a 09 46 44 5f 53 | 45 54 28 6f 75 74 73 6f |);..FD_S|ET(outso|
|00001fd0| 63 6b 2c 20 26 66 64 73 | 65 74 29 3b 0a 09 69 66 |ck, &fds|et);..if|
|00001fe0| 20 28 73 65 6c 65 63 74 | 28 67 65 74 64 74 61 62 | (select|(getdtab|
|00001ff0| 6c 65 73 69 7a 65 28 29 | 2c 20 26 66 64 73 65 74 |lesize()|, &fdset|
|00002000| 2c 20 30 2c 20 30 2c 20 | 30 29 20 3d 3d 20 2d 31 |, 0, 0, |0) == -1|
|00002010| 29 20 7b 0a 09 20 20 20 | 20 70 65 72 72 6f 72 28 |) {.. | perror(|
|00002020| 22 73 65 6c 65 63 74 22 | 29 3b 0a 09 20 20 20 20 |"select"|);.. |
|00002030| 65 78 69 74 28 31 29 3b | 0a 09 20 20 20 20 7d 0a |exit(1);|.. }.|
|00002040| 09 62 7a 65 72 6f 28 62 | 75 66 2c 20 31 30 32 34 |.bzero(b|uf, 1024|
|00002050| 29 3b 0a 0a 09 69 66 20 | 28 46 44 5f 49 53 53 45 |);...if |(FD_ISSE|
|00002060| 54 28 6d 73 67 73 6f 63 | 6b 2c 20 26 66 64 73 65 |T(msgsoc|k, &fdse|
|00002070| 74 29 20 26 26 20 46 44 | 5f 49 53 53 45 54 28 6f |t) && FD|_ISSET(o|
|00002080| 75 74 73 6f 63 6b 2c 20 | 26 66 64 73 65 74 29 29 |utsock, |&fdset))|
|00002090| 0a 09 20 20 20 20 66 70 | 72 69 6e 74 66 28 73 74 |.. fp|rintf(st|
|000020a0| 64 65 72 72 2c 22 54 77 | 6f 20 74 61 6c 6b 65 72 |derr,"Tw|o talker|
|000020b0| 73 20 2d 20 6e 6f 20 6c | 69 73 74 65 6e 65 72 73 |s - no l|isteners|
|000020c0| 5c 6e 22 29 3b 0a 0a 0a | 09 2f 2a 20 43 6c 69 65 |\n");...|./* Clie|
|000020d0| 6e 74 20 69 73 20 74 61 | 6c 6b 69 6e 67 20 74 6f |nt is ta|lking to|
|000020e0| 20 73 65 72 76 65 72 20 | 2a 2f 0a 0a 09 69 66 20 | server |*/...if |
|000020f0| 28 46 44 5f 49 53 53 45 | 54 28 6d 73 67 73 6f 63 |(FD_ISSE|T(msgsoc|
|00002100| 6b 2c 20 26 66 64 73 65 | 74 29 29 20 7b 20 0a 09 |k, &fdse|t)) { ..|
|00002110| 20 20 20 20 69 66 20 28 | 28 72 76 61 6c 20 3d 20 | if (|(rval = |
|00002120| 72 65 61 64 28 6d 73 67 | 73 6f 63 6b 2c 20 62 75 |read(msg|sock, bu|
|00002130| 66 2c 20 31 30 32 34 29 | 29 20 3c 20 30 29 0a 09 |f, 1024)|) < 0)..|
|00002140| 09 70 65 72 72 6f 72 28 | 22 72 65 61 64 69 6e 67 |.perror(|"reading|
|00002150| 20 73 74 72 65 61 6d 20 | 6d 65 73 73 61 67 65 22 | stream |message"|
|00002160| 29 3b 0a 09 20 20 20 20 | 69 66 20 28 72 76 61 6c |);.. |if (rval|
|00002170| 20 3d 3d 20 30 29 0a 09 | 09 66 70 72 69 6e 74 66 | == 0)..|.fprintf|
|00002180| 28 73 74 64 65 72 72 2c | 22 45 6e 64 69 6e 67 20 |(stderr,|"Ending |
|00002190| 63 6c 69 65 6e 74 20 63 | 6f 6e 6e 65 63 74 69 6f |client c|onnectio|
|000021a0| 6e 5c 6e 22 29 3b 0a 09 | 20 20 20 20 65 6c 73 65 |n\n");..| else|
|000021b0| 20 7b 0a 09 09 77 72 69 | 74 65 28 6f 75 74 66 69 | {...wri|te(outfi|
|000021c0| 6c 65 31 2c 20 62 75 66 | 2c 20 72 76 61 6c 29 3b |le1, buf|, rval);|
|000021d0| 0a 09 09 77 72 69 74 65 | 28 6f 75 74 66 69 6c 65 |...write|(outfile|
|000021e0| 31 2c 20 4d 41 52 4b 2c | 20 36 29 3b 0a 09 09 69 |1, MARK,| 6);...i|
|000021f0| 66 20 28 77 72 69 74 65 | 28 6f 75 74 73 6f 63 6b |f (write|(outsock|
|00002200| 2c 20 62 75 66 2c 20 72 | 76 61 6c 29 20 3c 20 30 |, buf, r|val) < 0|
|00002210| 29 0a 09 09 20 20 20 20 | 70 65 72 72 6f 72 28 22 |)... |perror("|
|00002220| 77 72 69 74 69 6e 67 20 | 6f 6e 20 6f 75 74 70 75 |writing |on outpu|
|00002230| 74 20 73 74 72 65 61 6d | 20 73 6f 63 6b 65 74 22 |t stream| socket"|
|00002240| 29 3b 0a 09 09 7d 0a 09 | 20 20 20 20 7d 0a 0a 09 |);...}..| }...|
|00002250| 2f 2a 20 53 65 72 76 65 | 72 20 69 73 20 74 61 6c |/* Serve|r is tal|
|00002260| 6b 69 6e 67 20 74 6f 20 | 63 6c 69 65 6e 74 20 2a |king to |client *|
|00002270| 2f 0a 0a 09 65 6c 73 65 | 20 7b 0a 09 20 20 20 20 |/...else| {.. |
|00002280| 69 66 20 28 21 20 46 44 | 5f 49 53 53 45 54 28 6f |if (! FD|_ISSET(o|
|00002290| 75 74 73 6f 63 6b 2c 20 | 26 66 64 73 65 74 29 29 |utsock, |&fdset))|
|000022a0| 20 7b 0a 09 09 70 65 72 | 72 6f 72 28 22 77 65 69 | {...per|ror("wei|
|000022b0| 72 64 20 62 65 68 61 76 | 69 6f 72 22 29 3b 0a 09 |rd behav|ior");..|
|000022c0| 09 65 78 69 74 28 31 29 | 3b 0a 09 09 7d 0a 09 20 |.exit(1)|;...}.. |
|000022d0| 20 20 20 69 66 20 28 28 | 72 76 61 6c 20 3d 20 72 | if ((|rval = r|
|000022e0| 65 61 64 28 6f 75 74 73 | 6f 63 6b 2c 20 62 75 66 |ead(outs|ock, buf|
|000022f0| 2c 20 31 30 32 34 29 29 | 20 3c 20 30 29 0a 09 09 |, 1024))| < 0)...|
|00002300| 70 65 72 72 6f 72 28 22 | 72 65 61 64 69 6e 67 20 |perror("|reading |
|00002310| 73 74 72 65 61 6d 20 6d | 65 73 73 61 67 65 22 29 |stream m|essage")|
|00002320| 3b 0a 09 20 20 20 20 69 | 66 20 28 72 76 61 6c 20 |;.. i|f (rval |
|00002330| 3d 3d 20 30 29 0a 09 09 | 66 70 72 69 6e 74 66 28 |== 0)...|fprintf(|
|00002340| 73 74 64 65 72 72 2c 22 | 45 6e 64 69 6e 67 20 73 |stderr,"|Ending s|
|00002350| 65 72 76 65 72 20 63 6f | 6e 6e 65 63 74 69 6f 6e |erver co|nnection|
|00002360| 5c 6e 22 29 3b 0a 09 20 | 20 20 20 65 6c 73 65 20 |\n");.. | else |
|00002370| 7b 0a 09 09 77 72 69 74 | 65 28 6f 75 74 66 69 6c |{...writ|e(outfil|
|00002380| 65 32 2c 20 62 75 66 2c | 20 72 76 61 6c 29 3b 0a |e2, buf,| rval);.|
|00002390| 09 09 77 72 69 74 65 28 | 6f 75 74 66 69 6c 65 32 |..write(|outfile2|
|000023a0| 2c 20 4d 41 52 4b 2c 20 | 36 29 3b 0a 09 09 69 66 |, MARK, |6);...if|
|000023b0| 20 28 77 72 69 74 65 28 | 6d 73 67 73 6f 63 6b 2c | (write(|msgsock,|
|000023c0| 20 62 75 66 2c 20 72 76 | 61 6c 29 20 3c 20 30 29 | buf, rv|al) < 0)|
|000023d0| 0a 09 09 20 20 20 20 70 | 65 72 72 6f 72 28 22 77 |... p|error("w|
|000023e0| 72 69 74 69 6e 67 20 6f | 6e 20 6f 75 74 70 75 74 |riting o|n output|
|000023f0| 20 73 74 72 65 61 6d 20 | 73 6f 63 6b 65 74 22 29 | stream |socket")|
|00002400| 3b 0a 09 09 7d 0a 09 20 | 20 20 20 7d 0a 09 7d 20 |;...}.. | }..} |
|00002410| 77 68 69 6c 65 20 28 72 | 76 61 6c 20 21 3d 20 30 |while (r|val != 0|
|00002420| 29 3b 0a 0a 0a 20 20 20 | 20 2f 2a 20 43 6c 6f 73 |);... | /* Clos|
|00002430| 65 20 75 70 20 73 68 6f | 70 20 2a 2f 0a 0a 20 20 |e up sho|p */.. |
|00002440| 20 20 66 70 72 69 6e 74 | 66 28 73 74 64 65 72 72 | fprint|f(stderr|
|00002450| 2c 20 22 43 6c 6f 73 69 | 6e 67 20 43 6f 6e 6e 65 |, "Closi|ng Conne|
|00002460| 63 74 69 6f 6e 73 5c 6e | 22 29 3b 0a 20 20 20 20 |ctions\n|");. |
|00002470| 63 6c 6f 73 65 28 6d 73 | 67 73 6f 63 6b 29 3b 0a |close(ms|gsock);.|
|00002480| 20 20 20 20 63 6c 6f 73 | 65 28 6f 75 74 73 6f 63 | clos|e(outsoc|
|00002490| 6b 29 3b 0a 20 20 20 20 | 63 6c 6f 73 65 28 6f 75 |k);. |close(ou|
|000024a0| 74 66 69 6c 65 31 29 3b | 0a 20 20 20 20 63 6c 6f |tfile1);|. clo|
|000024b0| 73 65 28 6f 75 74 66 69 | 6c 65 32 29 3b 0a 20 20 |se(outfi|le2);. |
|000024c0| 20 20 7d 0a 53 48 41 52 | 5f 45 4f 46 0a 66 69 20 | }.SHAR|_EOF.fi |
|000024d0| 23 20 65 6e 64 20 6f 66 | 20 6f 76 65 72 77 72 69 |# end of| overwri|
|000024e0| 74 69 6e 67 20 63 68 65 | 63 6b 0a 23 09 45 6e 64 |ting che|ck.#.End|
|000024f0| 20 6f 66 20 73 68 65 6c | 6c 20 61 72 63 68 69 76 | of shel|l archiv|
|00002500| 65 0a 65 78 69 74 20 30 | 0a |e.exit 0|. |
+--------+-------------------------+-------------------------+--------+--------+