home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume08 / bug < prev    next >
SHell self-extracting ARchive  |  1991-08-27  |  9.6 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

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

You can browse this item here: bug

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file C source text default
99% file C source, ASCII text default
100% TrID E-Mail message (Var. 2) 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)
100% xdgMime application/mbox default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 46 72 6f 6d 20 64 65 63 | 77 72 6c 21 75 63 62 76 |From dec|wrl!ucbv|
|00000010| 61 78 21 61 67 61 74 65 | 21 61 70 70 6c 65 21 67 |ax!agate|!apple!g|
|00000020| 65 6d 2e 6d 70 73 2e 6f | 68 69 6f 2d 73 74 61 74 |em.mps.o|hio-stat|
|00000030| 65 2e 65 64 75 21 67 69 | 6e 6f 73 6b 6f 21 75 75 |e.edu!gi|nosko!uu|
|00000040| 6e 65 74 21 61 6c 6c 62 | 65 72 79 20 53 75 6e 20 |net!allb|ery Sun |
|00000050| 4f 63 74 20 20 31 20 31 | 35 3a 33 38 3a 30 39 20 |Oct 1 1|5:38:09 |
|00000060| 50 44 54 20 31 39 38 39 | 0a 41 72 74 69 63 6c 65 |PDT 1989|.Article|
|00000070| 20 31 31 30 36 20 6f 66 | 20 63 6f 6d 70 2e 73 6f | 1106 of| comp.so|
|00000080| 75 72 63 65 73 2e 6d 69 | 73 63 3a 0a 50 61 74 68 |urces.mi|sc:.Path|
|00000090| 3a 20 64 65 63 77 72 6c | 21 75 63 62 76 61 78 21 |: decwrl|!ucbvax!|
|000000a0| 61 67 61 74 65 21 61 70 | 70 6c 65 21 67 65 6d 2e |agate!ap|ple!gem.|
|000000b0| 6d 70 73 2e 6f 68 69 6f | 2d 73 74 61 74 65 2e 65 |mps.ohio|-state.e|
|000000c0| 64 75 21 67 69 6e 6f 73 | 6b 6f 21 75 75 6e 65 74 |du!ginos|ko!uunet|
|000000d0| 21 61 6c 6c 62 65 72 79 | 0a 46 72 6f 6d 3a 20 61 |!allbery|.From: a|
|000000e0| 6c 6c 62 65 72 79 40 75 | 75 6e 65 74 2e 55 55 2e |llbery@u|unet.UU.|
|000000f0| 4e 45 54 20 28 42 72 61 | 6e 64 6f 6e 20 53 2e 20 |NET (Bra|ndon S. |
|00000100| 41 6c 6c 62 65 72 79 20 | 2d 20 63 6f 6d 70 2e 73 |Allbery |- comp.s|
|00000110| 6f 75 72 63 65 73 2e 6d | 69 73 63 29 0a 4e 65 77 |ources.m|isc).New|
|00000120| 73 67 72 6f 75 70 73 3a | 20 63 6f 6d 70 2e 73 6f |sgroups:| comp.so|
|00000130| 75 72 63 65 73 2e 6d 69 | 73 63 0a 53 75 62 6a 65 |urces.mi|sc.Subje|
|00000140| 63 74 3a 20 76 30 38 69 | 30 36 34 3a 20 62 75 67 |ct: v08i|064: bug|
|00000150| 20 2d 2d 20 6d 61 6b 65 | 20 61 20 74 72 61 6e 73 | -- make| a trans|
|00000160| 63 72 69 70 74 20 6f 66 | 20 61 20 73 6f 63 6b 65 |cript of| a socke|
|00000170| 74 20 63 6f 6e 6e 65 63 | 74 69 6f 6e 0a 4d 65 73 |t connec|tion.Mes|
|00000180| 73 61 67 65 2d 49 44 3a | 20 3c 36 38 39 32 32 40 |sage-ID:| <68922@|
|00000190| 75 75 6e 65 74 2e 55 55 | 2e 4e 45 54 3e 0a 44 61 |uunet.UU|.NET>.Da|
|000001a0| 74 65 3a 20 31 20 4f 63 | 74 20 38 39 20 31 34 3a |te: 1 Oc|t 89 14:|
|000001b0| 33 36 3a 32 33 20 47 4d | 54 0a 53 65 6e 64 65 72 |36:23 GM|T.Sender|
|000001c0| 3a 20 61 6c 6c 62 65 72 | 79 40 75 75 6e 65 74 2e |: allber|y@uunet.|
|000001d0| 55 55 2e 4e 45 54 0a 52 | 65 70 6c 79 2d 54 6f 3a |UU.NET.R|eply-To:|
|000001e0| 20 6d 61 74 74 68 65 77 | 40 43 53 2e 55 43 4c 41 | matthew|@CS.UCLA|
|000001f0| 2e 45 44 55 20 28 4d 61 | 74 74 68 65 77 20 4d 65 |.EDU (Ma|tthew Me|
|00000200| 72 7a 62 61 63 68 65 72 | 29 0a 4c 69 6e 65 73 3a |rzbacher|).Lines:|
|00000210| 20 33 32 36 0a 41 70 70 | 72 6f 76 65 64 3a 20 61 | 326.App|roved: a|
|00000220| 6c 6c 62 65 72 79 40 75 | 75 6e 65 74 2e 55 55 2e |llbery@u|unet.UU.|
|00000230| 4e 45 54 20 28 42 72 61 | 6e 64 6f 6e 20 53 2e 20 |NET (Bra|ndon S. |
|00000240| 41 6c 6c 62 65 72 79 20 | 2d 20 63 6f 6d 70 2e 73 |Allbery |- comp.s|
|00000250| 6f 75 72 63 65 73 2e 6d | 69 73 63 29 0a 0a 50 6f |ources.m|isc)..Po|
|00000260| 73 74 69 6e 67 2d 6e 75 | 6d 62 65 72 3a 20 56 6f |sting-nu|mber: Vo|
|00000270| 6c 75 6d 65 20 38 2c 20 | 49 73 73 75 65 20 36 34 |lume 8, |Issue 64|
|00000280| 0a 53 75 62 6d 69 74 74 | 65 64 2d 62 79 3a 20 6d |.Submitt|ed-by: m|
|00000290| 61 74 74 68 65 77 40 43 | 53 2e 55 43 4c 41 2e 45 |atthew@C|S.UCLA.E|
|000002a0| 44 55 20 28 4d 61 74 74 | 68 65 77 20 4d 65 72 7a |DU (Matt|hew Merz|
|000002b0| 62 61 63 68 65 72 29 0a | 41 72 63 68 69 76 65 2d |bacher).|Archive-|
|000002c0| 6e 61 6d 65 3a 20 62 75 | 67 0a 0a 23 21 20 2f 62 |name: bu|g..#! /b|
|000002d0| 69 6e 2f 73 68 0a 23 20 | 54 68 69 73 20 69 73 20 |in/sh.# |This is |
|000002e0| 61 20 73 68 65 6c 6c 20 | 61 72 63 68 69 76 65 2c |a shell |archive,|
|000002f0| 20 6d 65 61 6e 69 6e 67 | 3a 0a 23 20 31 2e 20 52 | meaning|:.# 1. R|
|00000300| 65 6d 6f 76 65 20 65 76 | 65 72 79 74 68 69 6e 67 |emove ev|erything|
|00000310| 20 61 62 6f 76 65 20 74 | 68 65 20 23 21 20 2f 62 | above t|he #! /b|
|00000320| 69 6e 2f 73 68 20 6c 69 | 6e 65 2e 0a 23 20 32 2e |in/sh li|ne..# 2.|
|00000330| 20 53 61 76 65 20 74 68 | 65 20 72 65 73 75 6c 74 | Save th|e result|
|00000340| 69 6e 67 20 74 65 78 74 | 20 69 6e 20 61 20 66 69 |ing text| in a fi|
|00000350| 6c 65 2e 0a 23 20 33 2e | 20 45 78 65 63 75 74 65 |le..# 3.| Execute|
|00000360| 20 74 68 65 20 66 69 6c | 65 20 77 69 74 68 20 2f | the fil|e with /|
|00000370| 62 69 6e 2f 73 68 20 28 | 6e 6f 74 20 63 73 68 29 |bin/sh (|not csh)|
|00000380| 20 74 6f 20 63 72 65 61 | 74 65 20 74 68 65 20 66 | to crea|te the f|
|00000390| 69 6c 65 73 3a 0a 23 09 | 52 45 41 44 4d 45 0a 23 |iles:.#.|README.#|
|000003a0| 09 62 75 67 2e 31 0a 23 | 09 62 75 67 2e 63 0a 23 |.bug.1.#|.bug.c.#|
|000003b0| 20 54 68 69 73 20 61 72 | 63 68 69 76 65 20 63 72 | This ar|chive cr|
|000003c0| 65 61 74 65 64 3a 20 46 | 72 69 20 53 65 70 20 32 |eated: F|ri Sep 2|
|000003d0| 39 20 31 38 3a 32 39 3a | 35 32 20 31 39 38 39 0a |9 18:29:|52 1989.|
|000003e0| 65 78 70 6f 72 74 20 50 | 41 54 48 3b 20 50 41 54 |export P|ATH; PAT|
|000003f0| 48 3d 2f 62 69 6e 3a 24 | 50 41 54 48 0a 69 66 20 |H=/bin:$|PATH.if |
|00000400| 74 65 73 74 20 2d 66 20 | 27 52 45 41 44 4d 45 27 |test -f |'README'|
|00000410| 0a 74 68 65 6e 0a 09 65 | 63 68 6f 20 73 68 61 72 |.then..e|cho shar|
|00000420| 3a 20 77 69 6c 6c 20 6e | 6f 74 20 6f 76 65 72 2d |: will n|ot over-|
|00000430| 77 72 69 74 65 20 65 78 | 69 73 74 69 6e 67 20 66 |write ex|isting f|
|00000440| 69 6c 65 20 22 27 52 45 | 41 44 4d 45 27 22 0a 65 |ile "'RE|ADME'".e|
|00000450| 6c 73 65 0a 63 61 74 20 | 3c 3c 20 5c 53 48 41 52 |lse.cat |<< \SHAR|
|00000460| 5f 45 4f 46 20 3e 20 27 | 52 45 41 44 4d 45 27 0a |_EOF > '|README'.|
|00000470| 42 75 67 20 69 73 20 75 | 73 65 64 20 74 6f 20 74 |Bug is u|sed to t|
|00000480| 61 70 20 61 20 73 74 72 | 65 61 6d 20 73 6f 63 6b |ap a str|eam sock|
|00000490| 65 74 2e 20 20 49 74 20 | 69 73 20 75 73 65 66 75 |et. It |is usefu|
|000004a0| 6c 20 66 6f 72 20 74 72 | 61 63 69 6e 67 20 63 6f |l for tr|acing co|
|000004b0| 6d 6d 75 6e 69 63 61 74 | 69 6f 6e 20 0a 62 65 74 |mmunicat|ion .bet|
|000004c0| 77 65 65 6e 20 61 20 73 | 65 72 76 65 72 20 61 6e |ween a s|erver an|
|000004d0| 64 20 69 74 73 20 63 6c | 69 65 6e 74 73 2e 20 20 |d its cl|ients. |
|000004e0| 54 68 65 20 63 6f 6d 6d | 75 6e 69 63 61 74 69 6f |The comm|unicatio|
|000004f0| 6e 20 62 65 74 77 65 65 | 6e 20 73 65 72 76 65 72 |n betwee|n server|
|00000500| 20 61 6e 64 0a 63 6c 69 | 65 6e 74 20 69 73 20 6d | and.cli|ent is m|
|00000510| 61 69 6e 74 61 69 6e 65 | 64 20 77 68 69 6c 65 20 |aintaine|d while |
|00000520| 74 72 61 6e 73 63 72 69 | 70 74 73 20 6f 66 20 61 |transcri|pts of a|
|00000530| 6c 6c 20 63 6f 6d 6d 75 | 6e 69 63 61 74 69 6f 6e |ll commu|nication|
|00000540| 20 6c 69 6e 65 73 20 61 | 72 65 20 74 61 6b 65 6e | lines a|re taken|
|00000550| 2e 0a 0a 54 68 65 72 65 | 20 69 73 20 61 20 6d 61 |...There| is a ma|
|00000560| 6e 20 70 61 67 65 20 28 | 62 75 67 2e 31 29 2c 20 |n page (|bug.1), |
|00000570| 61 20 73 6f 75 72 63 65 | 20 66 69 6c 65 20 28 62 |a source| file (b|
|00000580| 75 67 2e 63 29 20 61 6e | 64 20 74 68 69 73 20 66 |ug.c) an|d this f|
|00000590| 69 6c 65 20 28 52 45 41 | 44 4d 45 29 0a 69 6e 63 |ile (REA|DME).inc|
|000005a0| 6c 75 64 65 64 20 69 6e | 20 74 68 69 73 20 61 72 |luded in| this ar|
|000005b0| 63 68 69 76 65 2e 20 20 | 4e 6f 20 4d 61 6b 65 66 |chive. |No Makef|
|000005c0| 69 6c 65 20 69 73 20 6e | 65 63 65 73 73 61 72 79 |ile is n|ecessary|
|000005d0| 2c 20 73 69 6e 63 65 20 | 74 6f 20 22 6d 61 6b 65 |, since |to "make|
|000005e0| 22 20 69 74 2c 20 61 6c | 6c 0a 79 6f 75 20 64 6f |" it, al|l.you do|
|000005f0| 20 69 73 3a 0a 20 20 20 | 20 63 63 20 2d 6f 20 62 | is:. | cc -o b|
|00000600| 75 67 20 62 75 67 2e 63 | 0a 0a 59 6f 75 20 6e 65 |ug bug.c|..You ne|
|00000610| 65 64 20 74 6f 20 62 65 | 20 72 75 6e 6e 69 6e 67 |ed to be| running|
|00000620| 20 61 20 42 53 44 20 6f | 72 20 42 53 44 2d 64 65 | a BSD o|r BSD-de|
|00000630| 72 69 76 65 64 20 73 79 | 73 74 65 6d 20 28 73 69 |rived sy|stem (si|
|00000640| 6e 63 65 20 69 74 20 65 | 78 61 6d 69 6e 65 73 20 |nce it e|xamines |
|00000650| 73 6f 63 6b 65 74 73 29 | 2e 0a 49 74 20 68 61 73 |sockets)|..It has|
|00000660| 20 62 65 65 6e 20 74 65 | 73 74 65 64 20 75 6e 64 | been te|sted und|
|00000670| 65 72 20 53 75 6e 4f 53 | 20 34 2e 30 2e 33 0a 0a |er SunOS| 4.0.3..|
|00000680| 49 66 20 79 6f 75 20 64 | 6f 6e 27 74 20 6c 69 6b |If you d|on't lik|
|00000690| 65 20 6d 79 20 4d 41 52 | 4b 2c 20 79 6f 75 20 63 |e my MAR|K, you c|
|000006a0| 61 6e 20 63 68 61 6e 67 | 65 20 69 74 20 62 79 20 |an chang|e it by |
|000006b0| 63 68 61 6e 67 69 6e 67 | 20 74 68 65 20 6c 69 6e |changing| the lin|
|000006c0| 65 73 0a 23 64 65 66 69 | 6e 65 20 4d 41 52 4b 0a |es.#defi|ne MARK.|
|000006d0| 61 6e 64 0a 23 64 65 66 | 69 6e 65 20 4d 41 52 4b |and.#def|ine MARK|
|000006e0| 4c 45 4e 0a 74 6f 20 79 | 6f 75 72 20 6f 77 6e 20 |LEN.to y|our own |
|000006f0| 76 61 6c 75 65 73 2e 0a | 0a 49 27 64 20 62 65 20 |values..|.I'd be |
|00000700| 69 6e 74 65 72 65 73 74 | 65 64 20 69 6e 20 68 65 |interest|ed in he|
|00000710| 61 72 69 6e 67 20 77 68 | 61 74 20 70 65 6f 70 6c |aring wh|at peopl|
|00000720| 65 20 68 61 76 65 20 74 | 6f 20 73 61 79 20 61 6e |e have t|o say an|
|00000730| 64 20 77 68 61 74 20 74 | 68 65 79 20 75 73 65 20 |d what t|hey use |
|00000740| 27 62 75 67 27 0a 66 6f | 72 2e 20 20 49 20 68 6f |'bug'.fo|r. I ho|
|00000750| 70 65 20 49 20 68 61 76 | 65 6e 27 74 20 72 65 2d |pe I hav|en't re-|
|00000760| 69 6e 76 65 6e 74 65 64 | 20 74 68 65 20 77 68 65 |invented| the whe|
|00000770| 65 6c 2e 20 20 42 75 67 | 73 2f 43 6f 6d 6d 65 6e |el. Bug|s/Commen|
|00000780| 74 73 2f 51 75 65 73 74 | 69 6f 6e 73 2f 48 61 74 |ts/Quest|ions/Hat|
|00000790| 65 20 0a 4d 61 69 6c 20 | 74 6f 20 6d 65 2c 0a 0a |e .Mail |to me,..|
|000007a0| 4d 61 74 74 68 65 77 20 | 4d 65 72 7a 62 61 63 68 |Matthew |Merzbach|
|000007b0| 65 72 09 41 52 50 41 3a | 09 6d 61 74 74 68 65 77 |er.ARPA:|.matthew|
|000007c0| 40 43 53 2e 55 43 4c 41 | 2e 45 44 55 0a 09 20 20 |@CS.UCLA|.EDU.. |
|000007d0| 09 09 55 55 43 50 3a 09 | 2e 2e 2e 21 7b 75 75 6e |..UUCP:.|...!{uun|
|000007e0| 65 74 7c 72 75 74 67 65 | 72 73 7c 75 63 62 76 61 |et|rutge|rs|ucbva|
|000007f0| 78 7d 21 63 73 2e 75 63 | 6c 61 2e 65 64 75 21 6d |x}!cs.uc|la.edu!m|
|00000800| 61 74 74 68 65 77 0a 53 | 48 41 52 5f 45 4f 46 0a |atthew.S|HAR_EOF.|
|00000810| 66 69 20 23 20 65 6e 64 | 20 6f 66 20 6f 76 65 72 |fi # end| of over|
|00000820| 77 72 69 74 69 6e 67 20 | 63 68 65 63 6b 0a 69 66 |writing |check.if|
|00000830| 20 74 65 73 74 20 2d 66 | 20 27 62 75 67 2e 31 27 | test -f| 'bug.1'|
|00000840| 0a 74 68 65 6e 0a 09 65 | 63 68 6f 20 73 68 61 72 |.then..e|cho shar|
|00000850| 3a 20 77 69 6c 6c 20 6e | 6f 74 20 6f 76 65 72 2d |: will n|ot over-|
|00000860| 77 72 69 74 65 20 65 78 | 69 73 74 69 6e 67 20 66 |write ex|isting f|
|00000870| 69 6c 65 20 22 27 62 75 | 67 2e 31 27 22 0a 65 6c |ile "'bu|g.1'".el|
|00000880| 73 65 0a 63 61 74 20 3c | 3c 20 5c 53 48 41 52 5f |se.cat <|< \SHAR_|
|00000890| 45 4f 46 20 3e 20 27 62 | 75 67 2e 31 27 0a 2e 54 |EOF > 'b|ug.1'..T|
|000008a0| 48 20 42 55 47 20 31 0a | 5c 22 20 43 6f 70 79 72 |H BUG 1.|\" Copyr|
|000008b0| 69 67 68 74 20 28 43 29 | 20 31 39 38 39 20 62 79 |ight (C)| 1989 by|
|000008c0| 20 4d 61 74 74 68 65 77 | 20 4d 65 72 7a 62 61 63 | Matthew| Merzbac|
|000008d0| 68 65 72 2e 20 20 41 6c | 6c 20 52 69 67 68 74 73 |her. Al|l Rights|
|000008e0| 20 52 65 73 65 72 76 65 | 64 2e 0a 2e 53 48 20 4e | Reserve|d...SH N|
|000008f0| 41 4d 45 0a 62 75 67 20 | 5c 2d 20 6c 69 73 74 65 |AME.bug |\- liste|
|00000900| 6e 20 61 6e 64 20 74 72 | 61 6e 73 63 72 69 62 65 |n and tr|anscribe|
|00000910| 20 63 6f 6d 6d 75 6e 69 | 63 61 74 69 6f 6e 20 6f | communi|cation o|
|00000920| 6e 20 61 20 73 6f 63 6b | 65 74 0a 2e 53 48 20 53 |n a sock|et..SH S|
|00000930| 59 4e 4f 50 53 49 53 0a | 2e 42 20 62 75 67 0a 2e |YNOPSIS.|.B bug..|
|00000940| 6e 68 0a 69 6e 70 75 74 | 5f 70 6f 72 74 20 6f 75 |nh.input|_port ou|
|00000950| 74 70 75 74 5f 70 6f 72 | 74 20 6d 61 63 68 69 6e |tput_por|t machin|
|00000960| 65 20 63 6c 69 65 6e 74 | 5f 66 69 6c 65 20 73 65 |e client|_file se|
|00000970| 72 76 65 72 5f 66 69 6c | 65 0a 2e 68 79 0a 2e 53 |rver_fil|e..hy..S|
|00000980| 48 20 44 45 53 43 52 49 | 50 54 49 4f 4e 0a 2e 49 |H DESCRI|PTION..I|
|00000990| 20 62 75 67 0a 69 73 20 | 75 73 65 64 20 74 6f 20 | bug.is |used to |
|000009a0| 6c 69 73 74 65 6e 20 6f | 6e 20 61 20 73 70 65 63 |listen o|n a spec|
|000009b0| 69 66 69 65 64 20 5c 66 | 49 69 6e 70 75 74 5f 70 |ified \f|Iinput_p|
|000009c0| 6f 72 74 5c 66 52 20 61 | 6e 64 20 77 72 69 74 65 |ort\fR a|nd write|
|000009d0| 20 61 6e 20 65 78 61 63 | 74 0a 64 75 70 6c 69 63 | an exac|t.duplic|
|000009e0| 61 74 65 20 6f 75 74 20 | 74 6f 20 74 68 65 20 5c |ate out |to the \|
|000009f0| 66 49 6f 75 74 70 75 74 | 5f 70 6f 72 74 5c 66 52 |fIoutput|_port\fR|
|00000a00| 20 6f 6e 20 61 20 73 70 | 65 63 69 66 69 65 64 20 | on a sp|ecified |
|00000a10| 5c 66 49 6d 61 63 68 69 | 6e 65 5c 66 52 2e 20 20 |\fImachi|ne\fR. |
|00000a20| 49 74 20 0a 61 6c 73 6f | 20 77 72 69 74 65 73 20 |It .also| writes |
|00000a30| 61 20 74 72 61 6e 73 63 | 72 69 70 74 20 6f 66 20 |a transc|ript of |
|00000a40| 65 76 65 72 79 74 68 69 | 6e 67 20 74 68 61 74 20 |everythi|ng that |
|00000a50| 69 73 20 73 61 69 64 20 | 6f 6e 20 65 69 74 68 65 |is said |on eithe|
|00000a60| 72 20 70 6f 72 74 0a 74 | 6f 20 73 65 70 65 72 61 |r port.t|o sepera|
|00000a70| 74 65 20 66 69 6c 65 73 | 2e 20 20 45 61 63 68 20 |te files|. Each |
|00000a80| 70 69 65 63 65 20 6f 66 | 20 63 6f 6d 6d 75 6e 69 |piece of| communi|
|00000a90| 63 61 74 69 6f 6e 20 69 | 73 20 73 65 70 65 72 61 |cation i|s sepera|
|00000aa0| 74 65 64 20 62 79 20 61 | 20 4d 41 52 4b 2c 20 77 |ted by a| MARK, w|
|00000ab0| 68 69 63 68 0a 69 73 20 | 23 64 65 66 69 6e 65 64 |hich.is |#defined|
|00000ac0| 20 69 6e 20 74 68 65 20 | 63 6f 64 65 20 61 73 20 | in the |code as |
|00000ad0| 22 3c 4d 41 52 4b 3e 22 | 2e 0a 2e 50 50 0a 54 68 |"<MARK>"|...PP.Th|
|00000ae0| 65 20 6e 61 6d 69 6e 67 | 20 73 63 68 65 6d 65 20 |e naming| scheme |
|00000af0| 66 6f 72 20 74 68 65 20 | 6f 75 74 70 75 74 20 66 |for the |output f|
|00000b00| 69 6c 65 73 20 69 73 20 | 5c 66 49 63 6c 69 65 6e |iles is |\fIclien|
|00000b10| 74 5f 66 69 6c 65 5c 66 | 52 20 28 66 6f 72 20 63 |t_file\f|R (for c|
|00000b20| 6f 6d 6d 75 6e 69 63 61 | 74 69 6f 6e 0a 72 65 63 |ommunica|tion.rec|
|00000b30| 65 69 76 65 64 20 66 72 | 6f 6d 20 74 68 65 20 5c |eived fr|om the \|
|00000b40| 66 49 69 6e 70 75 74 5f | 70 6f 72 74 5c 66 52 29 |fIinput_|port\fR)|
|00000b50| 20 6f 72 20 5c 66 49 73 | 65 72 76 65 72 5f 66 69 | or \fIs|erver_fi|
|00000b60| 6c 65 5c 66 52 20 28 66 | 6f 72 20 63 6f 6d 6d 75 |le\fR (f|or commu|
|00000b70| 6e 69 63 61 74 69 6f 6e | 20 0a 72 65 63 65 69 76 |nication| .receiv|
|00000b80| 65 64 20 66 72 6f 6d 20 | 74 68 65 20 5c 66 49 6f |ed from |the \fIo|
|00000b90| 75 74 70 75 74 5f 70 6f | 72 74 5c 66 52 29 20 66 |utput_po|rt\fR) f|
|00000ba0| 6f 6c 6c 6f 77 65 64 20 | 62 79 20 61 20 70 65 72 |ollowed |by a per|
|00000bb0| 69 6f 64 20 28 27 2e 27 | 29 20 66 6f 6c 6c 6f 77 |iod ('.'|) follow|
|00000bc0| 65 64 20 62 79 20 0a 74 | 68 65 20 70 72 6f 63 65 |ed by .t|he proce|
|00000bd0| 73 73 20 69 64 20 6f 66 | 20 74 68 65 20 62 75 67 |ss id of| the bug|
|00000be0| 20 70 72 6f 67 72 61 6d | 20 66 6f 6c 6c 6f 77 65 | program| followe|
|00000bf0| 64 20 62 79 20 61 20 70 | 65 72 69 6f 64 20 28 27 |d by a p|eriod ('|
|00000c00| 2e 27 29 20 66 6f 6c 6c | 6f 77 65 64 20 62 79 20 |.') foll|owed by |
|00000c10| 74 68 65 20 0a 70 72 6f | 63 65 73 73 20 69 64 20 |the .pro|cess id |
|00000c20| 6f 66 20 74 68 65 20 63 | 68 69 6c 64 20 6f 66 20 |of the c|hild of |
|00000c30| 62 75 67 20 77 68 69 63 | 68 20 61 63 74 75 61 6c |bug whic|h actual|
|00000c40| 6c 79 20 64 6f 65 73 20 | 74 68 65 20 6d 6f 6e 69 |ly does |the moni|
|00000c50| 74 6f 72 69 6e 67 2e 20 | 20 54 68 75 73 2c 20 66 |toring. | Thus, f|
|00000c60| 6f 72 20 0a 65 76 65 72 | 79 20 63 6f 6e 6e 65 63 |or .ever|y connec|
|00000c70| 74 69 6f 6e 20 6d 61 64 | 65 20 74 6f 20 74 68 65 |tion mad|e to the|
|00000c80| 20 69 6e 70 75 74 5f 70 | 6f 72 74 2c 20 74 68 65 | input_p|ort, the|
|00000c90| 72 65 20 77 69 6c 6c 20 | 62 65 20 74 77 6f 20 28 |re will |be two (|
|00000ca0| 75 6e 69 71 75 65 29 20 | 66 69 6c 65 73 20 0a 63 |unique) |files .c|
|00000cb0| 72 65 61 74 65 64 2e 0a | 2e 50 50 0a 54 68 65 20 |reated..|.PP.The |
|00000cc0| 6f 75 74 70 75 74 20 66 | 69 6c 65 73 20 61 72 65 |output f|iles are|
|00000cd0| 20 70 72 6f 62 61 62 6c | 79 20 62 65 73 74 20 72 | probabl|y best r|
|00000ce0| 65 61 64 20 62 79 20 75 | 73 69 6e 67 20 5c 66 49 |ead by u|sing \fI|
|00000cf0| 6f 64 5c 66 52 28 31 29 | 20 77 69 74 68 20 74 68 |od\fR(1)| with th|
|00000d00| 65 20 22 2d 63 22 20 0a | 6f 72 20 22 2d 63 78 22 |e "-c" .|or "-cx"|
|00000d10| 20 6f 70 74 69 6f 6e 73 | 2e 0a 2e 53 48 20 45 58 | options|...SH EX|
|00000d20| 41 4d 50 4c 45 0a 5c 66 | 49 62 75 67 5c 66 52 20 |AMPLE.\f|Ibug\fR |
|00000d30| 33 30 30 30 20 32 39 39 | 39 20 6d 6f 6f 73 65 62 |3000 299|9 mooseb|
|00000d40| 72 65 61 74 68 20 63 6c | 20 73 65 0a 2e 50 50 0a |reath cl| se..PP.|
|00000d50| 54 68 69 73 20 69 6e 76 | 6f 63 61 74 69 6f 6e 20 |This inv|ocation |
|00000d60| 77 69 6c 6c 20 63 72 65 | 61 74 65 2c 20 66 6f 72 |will cre|ate, for|
|00000d70| 20 65 76 65 72 79 20 63 | 6f 6e 6e 65 63 74 69 6f | every c|onnectio|
|00000d80| 6e 20 74 6f 20 70 6f 72 | 74 20 33 30 30 30 20 6f |n to por|t 3000 o|
|00000d90| 6e 20 74 68 65 20 63 75 | 72 72 65 6e 74 20 0a 6d |n the cu|rrent .m|
|00000da0| 61 63 68 69 6e 65 2c 20 | 74 77 6f 20 66 69 6c 65 |achine, |two file|
|00000db0| 73 20 28 63 6c 2e 70 69 | 64 2e 63 70 69 64 20 61 |s (cl.pi|d.cpid a|
|00000dc0| 6e 64 20 73 65 2e 70 69 | 64 2e 63 70 69 64 29 2e |nd se.pi|d.cpid).|
|00000dd0| 20 20 45 76 65 72 79 20 | 63 6f 6d 6d 75 6e 69 63 | Every |communic|
|00000de0| 61 74 69 6f 6e 20 74 6f | 20 70 6f 72 74 0a 33 30 |ation to| port.30|
|00000df0| 30 30 20 69 73 20 72 65 | 70 65 61 74 65 64 20 76 |00 is re|peated v|
|00000e00| 65 72 62 61 74 69 6d 20 | 74 6f 20 70 6f 72 74 20 |erbatim |to port |
|00000e10| 32 39 39 39 20 6f 6e 20 | 6d 61 63 68 69 6e 65 20 |2999 on |machine |
|00000e20| 22 6d 6f 6f 73 65 62 72 | 65 61 74 68 22 20 61 6e |"moosebr|eath" an|
|00000e30| 64 20 77 72 69 74 74 65 | 6e 20 74 6f 0a 74 68 65 |d writte|n to.the|
|00000e40| 20 66 69 72 73 74 20 66 | 69 6c 65 2e 20 20 41 6c | first f|ile. Al|
|00000e50| 6c 20 72 65 73 70 6f 6e | 73 65 73 20 61 72 65 20 |l respon|ses are |
|00000e60| 77 72 69 74 74 65 6e 20 | 74 6f 20 74 68 65 20 73 |written |to the s|
|00000e70| 65 63 6f 6e 64 20 66 69 | 6c 65 2e 0a 2e 53 48 20 |econd fi|le...SH |
|00000e80| 46 49 4c 45 53 0a 2e 62 | 72 0a 63 72 65 61 74 65 |FILES..b|r.create|
|00000e90| 73 20 66 69 6c 65 73 20 | 62 61 73 65 64 20 6f 6e |s files |based on|
|00000ea0| 20 5c 66 49 63 6c 69 65 | 6e 74 5f 66 69 6c 65 5c | \fIclie|nt_file\|
|00000eb0| 66 52 20 61 6e 64 20 5c | 66 49 73 65 72 76 65 72 |fR and \|fIserver|
|00000ec0| 5f 66 69 6c 65 5c 66 52 | 0a 2e 53 48 20 22 53 45 |_file\fR|..SH "SE|
|00000ed0| 45 20 41 4c 53 4f 22 0a | 6f 64 28 31 29 2c 20 73 |E ALSO".|od(1), s|
|00000ee0| 6f 63 6b 65 74 28 32 29 | 20 5b 61 6e 64 20 66 72 |ocket(2)| [and fr|
|00000ef0| 69 65 6e 64 73 5d 2c 20 | 66 6f 72 6b 28 32 29 2e |iends], |fork(2).|
|00000f00| 0a 2e 53 48 20 41 55 54 | 48 4f 52 0a 4d 61 74 74 |..SH AUT|HOR.Matt|
|00000f10| 68 65 77 20 4d 65 72 7a | 62 61 63 68 65 72 2c 20 |hew Merz|bacher, |
|00000f20| 62 75 67 73 2f 63 6f 6d | 6d 65 6e 74 73 20 2d 20 |bugs/com|ments - |
|00000f30| 6d 61 74 74 68 65 77 40 | 63 73 2e 75 63 6c 61 2e |matthew@|cs.ucla.|
|00000f40| 65 64 75 0a 2e 53 48 20 | 42 55 47 53 0a 2e 50 50 |edu..SH |BUGS..PP|
|00000f50| 0a 47 6f 6f 64 6e 65 73 | 73 20 6b 6e 6f 77 73 20 |.Goodnes|s knows |
|00000f60| 77 68 61 74 20 73 79 73 | 74 65 6d 73 20 74 68 69 |what sys|tems thi|
|00000f70| 73 20 77 69 6c 6c 20 61 | 63 74 75 61 6c 6c 79 20 |s will a|ctually |
|00000f80| 72 75 6e 20 6f 6e 2e 20 | 20 41 6e 79 20 42 53 44 |run on. | Any BSD|
|00000f90| 20 6f 72 20 0a 42 53 44 | 2d 64 65 72 69 76 65 64 | or .BSD|-derived|
|00000fa0| 20 73 79 73 74 65 6d 20 | 53 48 4f 55 4c 44 20 77 | system |SHOULD w|
|00000fb0| 6f 72 6b 2e 0a 0a 54 68 | 65 72 65 20 73 68 6f 75 |ork...Th|ere shou|
|00000fc0| 6c 64 20 62 65 20 61 6e | 20 6f 70 74 69 6f 6e 20 |ld be an| option |
|00000fd0| 74 6f 20 63 68 61 6e 67 | 65 20 74 68 65 20 4d 41 |to chang|e the MA|
|00000fe0| 52 4b 2e 0a 53 48 41 52 | 5f 45 4f 46 0a 66 69 20 |RK..SHAR|_EOF.fi |
|00000ff0| 23 20 65 6e 64 20 6f 66 | 20 6f 76 65 72 77 72 69 |# end of| overwri|
|00001000| 74 69 6e 67 20 63 68 65 | 63 6b 0a 69 66 20 74 65 |ting che|ck.if te|
|00001010| 73 74 20 2d 66 20 27 62 | 75 67 2e 63 27 0a 74 68 |st -f 'b|ug.c'.th|
|00001020| 65 6e 0a 09 65 63 68 6f | 20 73 68 61 72 3a 20 77 |en..echo| shar: w|
|00001030| 69 6c 6c 20 6e 6f 74 20 | 6f 76 65 72 2d 77 72 69 |ill not |over-wri|
|00001040| 74 65 20 65 78 69 73 74 | 69 6e 67 20 66 69 6c 65 |te exist|ing file|
|00001050| 20 22 27 62 75 67 2e 63 | 27 22 0a 65 6c 73 65 0a | "'bug.c|'".else.|
|00001060| 63 61 74 20 3c 3c 20 5c | 53 48 41 52 5f 45 4f 46 |cat << \|SHAR_EOF|
|00001070| 20 3e 20 27 62 75 67 2e | 63 27 0a 2f 2a 20 43 6f | > 'bug.|c'./* Co|
|00001080| 70 79 72 69 67 68 74 20 | 28 43 29 20 31 39 38 39 |pyright |(C) 1989|
|00001090| 20 62 79 20 4d 61 74 74 | 68 65 77 20 4d 65 72 7a | by Matt|hew Merz|
|000010a0| 62 61 63 68 65 72 2e 0a | 20 20 20 41 6c 6c 20 52 |bacher..| All R|
|000010b0| 69 67 68 74 73 20 52 65 | 73 65 72 76 65 64 2e 0a |ights Re|served..|
|000010c0| 20 20 20 42 75 67 20 69 | 73 20 70 72 6f 76 69 64 | Bug i|s provid|
|000010d0| 65 64 20 61 73 20 69 73 | 2c 20 77 69 74 68 6f 75 |ed as is|, withou|
|000010e0| 74 20 65 78 70 72 65 73 | 73 20 6f 72 20 69 6d 70 |t expres|s or imp|
|000010f0| 6c 69 65 64 20 77 61 72 | 72 61 6e 74 79 2e 20 20 |lied war|ranty. |
|00001100| 49 6e 20 6e 6f 20 65 76 | 65 6e 74 0a 20 20 20 73 |In no ev|ent. s|
|00001110| 68 61 6c 6c 20 4d 61 74 | 74 68 65 77 20 4d 65 72 |hall Mat|thew Mer|
|00001120| 7a 62 61 63 68 65 72 20 | 62 65 63 6f 6d 65 20 6c |zbacher |become l|
|00001130| 69 61 62 6c 65 20 66 6f | 72 20 61 6e 79 20 6c 6f |iable fo|r any lo|
|00001140| 73 73 20 6f 72 20 64 61 | 6d 61 67 65 73 2c 20 63 |ss or da|mages, c|
|00001150| 6f 6e 73 65 71 75 65 6e | 74 69 61 6c 0a 20 20 20 |onsequen|tial. |
|00001160| 6f 72 20 6f 74 68 65 72 | 77 69 73 65 2c 20 61 72 |or other|wise, ar|
|00001170| 69 73 69 6e 67 20 66 72 | 6f 6d 20 74 68 65 20 75 |ising fr|om the u|
|00001180| 73 65 20 6f 72 20 70 6f | 73 73 65 73 73 69 6f 6e |se or po|ssession|
|00001190| 20 6f 66 20 74 68 69 73 | 20 73 6f 66 74 77 61 72 | of this| softwar|
|000011a0| 65 2e 0a 2a 2f 0a 0a 23 | 69 6e 63 6c 75 64 65 20 |e..*/..#|include |
|000011b0| 3c 73 79 73 2f 74 79 70 | 65 73 2e 68 3e 0a 23 69 |<sys/typ|es.h>.#i|
|000011c0| 6e 63 6c 75 64 65 20 3c | 73 79 73 2f 73 6f 63 6b |nclude <|sys/sock|
|000011d0| 65 74 2e 68 3e 0a 23 69 | 6e 63 6c 75 64 65 20 3c |et.h>.#i|nclude <|
|000011e0| 6e 65 74 69 6e 65 74 2f | 69 6e 2e 68 3e 0a 23 69 |netinet/|in.h>.#i|
|000011f0| 6e 63 6c 75 64 65 20 3c | 6e 65 74 64 62 2e 68 3e |nclude <|netdb.h>|
|00001200| 0a 23 69 6e 63 6c 75 64 | 65 20 3c 73 74 64 69 6f |.#includ|e <stdio|
|00001210| 2e 68 3e 0a 23 69 6e 63 | 6c 75 64 65 20 3c 66 63 |.h>.#inc|lude <fc|
|00001220| 6e 74 6c 2e 68 3e 0a 0a | 23 64 65 66 69 6e 65 20 |ntl.h>..|#define |
|00001230| 4d 41 52 4b 20 22 3c 4d | 41 52 4b 3e 22 0a 23 64 |MARK "<M|ARK>".#d|
|00001240| 65 66 69 6e 65 20 4d 41 | 52 4b 4c 45 4e 20 36 0a |efine MA|RKLEN 6.|
|00001250| 0a 2f 2a 0a 20 2a 20 42 | 72 69 65 66 20 44 65 73 |./*. * B|rief Des|
|00001260| 63 72 69 70 74 69 6f 6e | 3a 0a 20 2a 20 42 75 67 |cription|:. * Bug|
|00001270| 20 69 73 20 75 73 65 64 | 20 74 6f 20 74 61 70 20 | is used| to tap |
|00001280| 61 20 73 74 72 65 61 6d | 20 73 6f 63 6b 65 74 2e |a stream| socket.|
|00001290| 20 20 49 74 20 69 73 20 | 75 73 65 66 75 6c 20 66 | It is |useful f|
|000012a0| 6f 72 20 74 72 61 63 69 | 6e 67 20 63 6f 6d 6d 75 |or traci|ng commu|
|000012b0| 6e 69 63 61 74 69 6f 6e | 20 0a 20 2a 20 62 65 74 |nication| . * bet|
|000012c0| 77 65 65 6e 20 61 20 73 | 65 72 76 65 72 20 61 6e |ween a s|erver an|
|000012d0| 64 20 69 74 73 20 63 6c | 69 65 6e 74 73 2e 20 20 |d its cl|ients. |
|000012e0| 54 68 65 20 63 6f 6d 6d | 75 6e 69 63 61 74 69 6f |The comm|unicatio|
|000012f0| 6e 20 62 65 74 77 65 65 | 6e 20 73 65 72 76 65 72 |n betwee|n server|
|00001300| 20 61 6e 64 0a 20 2a 20 | 63 6c 69 65 6e 74 20 69 | and. * |client i|
|00001310| 73 20 6d 61 69 6e 74 61 | 69 6e 65 64 20 77 68 69 |s mainta|ined whi|
|00001320| 6c 65 20 74 72 61 6e 73 | 63 72 69 70 74 73 20 6f |le trans|cripts o|
|00001330| 66 20 61 6c 6c 20 63 6f | 6d 6d 75 6e 69 63 61 74 |f all co|mmunicat|
|00001340| 69 6f 6e 20 6c 69 6e 65 | 73 20 61 72 65 20 74 61 |ion line|s are ta|
|00001350| 6b 65 6e 2e 0a 20 2a 20 | 49 74 20 68 61 73 20 73 |ken.. * |It has s|
|00001360| 69 78 20 72 65 71 75 69 | 72 65 64 20 28 61 6e 64 |ix requi|red (and|
|00001370| 20 6e 6f 20 6f 70 74 69 | 6f 6e 61 6c 29 20 61 72 | no opti|onal) ar|
|00001380| 67 75 6d 65 6e 74 73 2e | 20 20 0a 20 2a 0a 20 2a |guments.| . *. *|
|00001390| 20 55 73 61 67 65 3a 0a | 20 2a 20 62 75 67 20 3c | Usage:.| * bug <|
|000013a0| 69 6e 20 70 6f 72 74 3e | 20 3c 6f 75 74 20 70 6f |in port>| <out po|
|000013b0| 72 74 3e 20 3c 6d 61 63 | 68 69 6e 65 3e 20 3c 63 |rt> <mac|hine> <c|
|000013c0| 6c 69 65 6e 74 20 66 69 | 6c 65 3e 20 3c 73 65 72 |lient fi|le> <ser|
|000013d0| 76 65 72 20 66 69 6c 65 | 3e 0a 20 2a 0a 20 2a 20 |ver file|>. *. * |
|000013e0| 3c 69 6e 20 70 6f 72 74 | 3e 20 20 20 20 20 2d 20 |<in port|> - |
|000013f0| 74 68 65 20 70 6f 72 74 | 20 28 6f 6e 20 74 68 65 |the port| (on the|
|00001400| 20 6d 61 63 68 69 6e 65 | 20 6f 6e 20 77 68 69 63 | machine| on whic|
|00001410| 68 20 62 75 67 20 72 75 | 6e 73 29 20 74 6f 20 77 |h bug ru|ns) to w|
|00001420| 68 69 63 68 20 74 6f 0a | 20 2a 09 09 09 09 20 20 |hich to.| *.... |
|00001430| 20 63 6c 69 65 6e 74 73 | 20 77 69 6c 6c 20 63 6f | clients| will co|
|00001440| 6e 6e 65 63 74 20 28 74 | 68 65 20 70 73 65 75 64 |nnect (t|he pseud|
|00001450| 6f 2d 70 6f 72 74 29 0a | 20 2a 20 3c 6f 75 74 20 |o-port).| * <out |
|00001460| 70 6f 72 74 3e 20 20 20 | 20 2d 20 74 68 65 20 74 |port> | - the t|
|00001470| 72 75 65 20 73 65 72 76 | 65 72 20 70 6f 72 74 0a |rue serv|er port.|
|00001480| 20 2a 20 3c 6d 61 63 68 | 69 6e 65 3e 20 20 20 20 | * <mach|ine> |
|00001490| 20 2d 20 74 68 65 20 73 | 65 72 76 65 72 20 6d 61 | - the s|erver ma|
|000014a0| 63 68 69 6e 65 0a 20 2a | 20 3c 63 6c 69 65 6e 74 |chine. *| <client|
|000014b0| 20 66 69 6c 65 3e 20 2d | 20 74 72 61 6e 73 63 72 | file> -| transcr|
|000014c0| 69 70 74 20 66 69 6c 65 | 20 6f 66 20 77 68 61 74 |ipt file| of what|
|000014d0| 20 65 61 63 68 20 63 6c | 69 65 6e 74 20 73 61 79 | each cl|ient say|
|000014e0| 73 0a 20 2a 20 3c 73 65 | 72 76 65 72 20 66 69 6c |s. * <se|rver fil|
|000014f0| 65 3e 20 2d 20 74 72 61 | 6e 73 63 72 69 70 74 20 |e> - tra|nscript |
|00001500| 66 69 6c 65 20 6f 66 20 | 77 68 61 74 20 74 68 65 |file of |what the|
|00001510| 20 73 65 72 76 65 72 20 | 72 65 73 70 6f 6e 64 73 | server |responds|
|00001520| 0a 20 2a 0a 20 2a 20 45 | 78 61 6d 70 6c 65 3a 20 |. *. * E|xample: |
|00001530| 0a 20 2a 20 53 75 70 70 | 6f 73 65 20 61 20 73 65 |. * Supp|ose a se|
|00001540| 72 76 65 72 20 6c 69 73 | 74 65 6e 73 20 6f 6e 20 |rver lis|tens on |
|00001550| 70 6f 72 74 20 33 30 30 | 30 20 6f 66 20 6d 61 63 |port 300|0 of mac|
|00001560| 68 69 6e 65 20 22 78 79 | 7a 22 2e 20 20 54 68 65 |hine "xy|z". The|
|00001570| 20 75 73 65 72 20 6d 75 | 73 74 20 0a 20 2a 20 61 | user mu|st . * a|
|00001580| 72 74 69 66 69 63 69 61 | 6c 6c 79 20 6d 61 6b 65 |rtificia|lly make|
|00001590| 20 74 68 65 20 63 6c 69 | 65 6e 74 73 20 74 61 6c | the cli|ents tal|
|000015a0| 6b 20 74 6f 20 73 6f 6d | 65 20 6f 74 68 65 72 20 |k to som|e other |
|000015b0| 70 6f 72 74 20 28 6f 6e | 20 61 6e 79 20 6d 61 63 |port (on| any mac|
|000015c0| 68 69 6e 65 20 2d 0a 20 | 2a 20 69 74 20 63 6f 75 |hine -. |* it cou|
|000015d0| 6c 64 20 62 65 20 74 68 | 65 20 73 65 72 76 65 72 |ld be th|e server|
|000015e0| 20 6d 61 63 68 69 6e 65 | 2c 20 74 68 65 20 63 6c | machine|, the cl|
|000015f0| 69 65 6e 74 20 6d 61 63 | 68 69 6e 65 2c 20 6f 72 |ient mac|hine, or|
|00001600| 20 61 20 74 68 69 72 64 | 20 6d 61 63 68 69 6e 65 | a third| machine|
|00001610| 29 2e 0a 20 2a 20 54 68 | 61 74 20 70 6f 72 74 20 |).. * Th|at port |
|00001620| 69 73 20 63 61 6c 6c 65 | 64 20 74 68 65 20 70 73 |is calle|d the ps|
|00001630| 65 75 64 6f 2d 70 6f 72 | 74 2e 20 20 42 75 67 20 |eudo-por|t. Bug |
|00001640| 72 75 6e 73 20 6f 6e 20 | 74 68 65 20 6d 61 63 68 |runs on |the mach|
|00001650| 69 6e 65 20 6f 66 20 74 | 68 65 0a 20 2a 20 70 73 |ine of t|he. * ps|
|00001660| 65 75 64 6f 2d 70 6f 72 | 74 2e 20 20 54 6f 20 72 |eudo-por|t. To r|
|00001670| 75 6e 20 69 74 2c 20 74 | 79 70 65 3a 0a 20 2a 20 |un it, t|ype:. * |
|00001680| 0a 20 2a 20 62 75 67 20 | 32 39 39 39 20 33 30 30 |. * bug |2999 300|
|00001690| 30 20 78 79 7a 20 63 6c | 69 65 6e 74 20 73 65 72 |0 xyz cl|ient ser|
|000016a0| 76 65 72 0a 20 2a 0a 20 | 2a 20 54 68 69 73 20 61 |ver. *. |* This a|
|000016b0| 73 73 75 6d 65 73 20 74 | 68 61 74 20 74 68 65 20 |ssumes t|hat the |
|000016c0| 70 73 65 75 64 6f 2d 70 | 6f 72 74 20 69 73 20 32 |pseudo-p|ort is 2|
|000016d0| 39 39 39 2e 20 20 54 68 | 65 20 6f 75 74 70 75 74 |999. Th|e output|
|000016e0| 20 66 69 6c 65 73 20 77 | 69 6c 6c 20 61 6c 6c 20 | files w|ill all |
|000016f0| 73 74 61 72 74 0a 20 2a | 20 77 69 74 68 20 22 63 |start. *| with "c|
|00001700| 6c 69 65 6e 74 22 20 6f | 72 20 22 73 65 72 76 65 |lient" o|r "serve|
|00001710| 72 22 20 66 6f 6c 6c 6f | 77 65 64 20 62 79 20 74 |r" follo|wed by t|
|00001720| 68 65 20 70 72 6f 63 65 | 73 73 20 6e 75 6d 62 65 |he proce|ss numbe|
|00001730| 72 20 6f 66 20 74 68 65 | 20 62 75 67 20 70 72 6f |r of the| bug pro|
|00001740| 63 65 73 73 0a 20 2a 20 | 61 6e 64 20 74 68 65 20 |cess. * |and the |
|00001750| 70 72 6f 63 65 73 73 20 | 6e 75 6d 62 65 72 20 6f |process |number o|
|00001760| 66 20 65 61 63 68 20 73 | 65 70 65 72 61 74 65 20 |f each s|eperate |
|00001770| 6c 69 73 74 65 6e 69 6e | 67 20 73 65 73 73 69 6f |listenin|g sessio|
|00001780| 6e 2e 20 20 54 68 61 74 | 20 77 61 79 2c 20 79 6f |n. That| way, yo|
|00001790| 75 0a 20 2a 20 63 61 6e | 20 66 6f 6c 6c 6f 77 20 |u. * can| follow |
|000017a0| 74 68 65 20 63 6f 6e 6e | 65 63 74 69 6f 6e 20 6f |the conn|ection o|
|000017b0| 72 64 65 72 2e 20 20 54 | 79 70 69 63 61 6c 6c 79 |rder. T|ypically|
|000017c0| 2c 20 74 68 65 20 6f 75 | 74 70 75 74 20 66 69 6c |, the ou|tput fil|
|000017d0| 65 73 20 63 72 65 61 74 | 65 64 20 62 79 20 62 75 |es creat|ed by bu|
|000017e0| 67 0a 20 2a 20 6d 61 79 | 20 62 65 20 72 65 61 64 |g. * may| be read|
|000017f0| 20 62 79 20 75 73 69 6e | 67 20 27 6f 64 20 2d 63 | by usin|g 'od -c|
|00001800| 27 2e 0a 20 2a 0a 20 2a | 2f 0a 0a 6d 61 69 6e 28 |'.. *. *|/..main(|
|00001810| 61 72 67 63 2c 20 61 72 | 67 76 29 0a 69 6e 74 20 |argc, ar|gv).int |
|00001820| 61 72 67 63 3b 20 63 68 | 61 72 20 2a 61 72 67 76 |argc; ch|ar *argv|
|00001830| 5b 5d 3b 0a 7b 0a 20 20 | 20 20 73 74 72 75 63 74 |[];.{. | struct|
|00001840| 20 73 6f 63 6b 61 64 64 | 72 5f 69 6e 20 73 65 72 | sockadd|r_in ser|
|00001850| 76 65 72 3b 0a 20 20 20 | 20 73 74 72 75 63 74 20 |ver;. | struct |
|00001860| 68 6f 73 74 65 6e 74 20 | 2a 68 70 2c 20 2a 67 65 |hostent |*hp, *ge|
|00001870| 74 68 6f 73 74 62 79 6e | 61 6d 65 28 29 3b 0a 20 |thostbyn|ame();. |
|00001880| 20 20 20 63 68 61 72 20 | 62 75 66 5b 31 30 32 34 | char |buf[1024|
|00001890| 5d 3b 0a 20 20 20 20 69 | 6e 74 20 72 76 61 6c 3b |];. i|nt rval;|
|000018a0| 0a 20 20 20 20 69 6e 74 | 20 6f 75 74 66 69 6c 65 |. int| outfile|
|000018b0| 31 2c 20 6f 75 74 66 69 | 6c 65 32 3b 0a 20 20 20 |1, outfi|le2;. |
|000018c0| 20 69 6e 74 20 69 6e 73 | 6f 63 6b 2c 20 6f 75 74 | int ins|ock, out|
|000018d0| 73 6f 63 6b 2c 20 6d 73 | 67 73 6f 63 6b 3b 0a 20 |sock, ms|gsock;. |
|000018e0| 20 20 20 69 6e 74 20 69 | 6e 73 6f 63 6b 6e 75 6d | int i|nsocknum|
|000018f0| 2c 20 6f 75 74 73 6f 63 | 6b 6e 75 6d 3b 0a 20 20 |, outsoc|knum;. |
|00001900| 20 20 66 64 5f 73 65 74 | 20 66 64 73 65 74 3b 0a | fd_set| fdset;.|
|00001910| 0a 0a 20 20 20 20 2f 2a | 20 43 68 65 63 6b 20 41 |.. /*| Check A|
|00001920| 72 67 75 6d 65 6e 74 73 | 20 2a 2f 0a 0a 20 20 20 |rguments| */.. |
|00001930| 20 69 66 20 28 61 72 67 | 63 20 3c 20 36 29 20 7b | if (arg|c < 6) {|
|00001940| 0a 09 70 72 69 6e 74 66 | 28 22 75 73 61 67 65 3a |..printf|("usage:|
|00001950| 20 25 73 20 3c 69 6e 20 | 70 6f 72 74 3e 20 3c 6f | %s <in |port> <o|
|00001960| 75 74 20 70 6f 72 74 3e | 20 3c 6d 61 63 68 69 6e |ut port>| <machin|
|00001970| 65 3e 20 3c 63 6c 69 65 | 6e 74 20 66 69 6c 65 3e |e> <clie|nt file>|
|00001980| 20 3c 73 65 72 76 65 72 | 20 66 69 6c 65 3e 5c 6e | <server| file>\n|
|00001990| 22 2c 61 72 67 76 5b 30 | 5d 29 3b 0a 09 65 78 69 |",argv[0|]);..exi|
|000019a0| 74 28 31 29 3b 0a 09 7d | 0a 0a 20 20 20 20 69 6e |t(1);..}|.. in|
|000019b0| 73 6f 63 6b 6e 75 6d 20 | 3d 20 61 74 6f 69 28 61 |socknum |= atoi(a|
|000019c0| 72 67 76 5b 31 5d 29 3b | 0a 20 20 20 20 6f 75 74 |rgv[1]);|. out|
|000019d0| 73 6f 63 6b 6e 75 6d 20 | 3d 20 61 74 6f 69 28 61 |socknum |= atoi(a|
|000019e0| 72 67 76 5b 32 5d 29 3b | 0a 0a 0a 20 20 20 20 2f |rgv[2]);|... /|
|000019f0| 2a 20 43 72 65 61 74 65 | 20 6c 69 73 74 65 6e 69 |* Create| listeni|
|00001a00| 6e 67 20 70 6f 73 74 20 | 6f 6e 20 70 73 65 75 64 |ng post |on pseud|
|00001a10| 6f 2d 70 6f 72 74 20 2a | 2f 0a 0a 20 20 20 20 69 |o-port *|/.. i|
|00001a20| 6e 73 6f 63 6b 20 3d 20 | 73 6f 63 6b 65 74 28 41 |nsock = |socket(A|
|00001a30| 46 5f 49 4e 45 54 2c 20 | 53 4f 43 4b 5f 53 54 52 |F_INET, |SOCK_STR|
|00001a40| 45 41 4d 2c 20 30 29 3b | 0a 0a 20 20 20 20 69 66 |EAM, 0);|.. if|
|00001a50| 20 28 69 6e 73 6f 63 6b | 20 3c 20 30 29 20 7b 0a | (insock| < 0) {.|
|00001a60| 09 70 65 72 72 6f 72 28 | 22 6f 70 65 6e 69 6e 67 |.perror(|"opening|
|00001a70| 20 70 73 65 75 64 6f 2d | 70 6f 72 74 20 73 74 72 | pseudo-|port str|
|00001a80| 65 61 6d 20 73 6f 63 6b | 65 74 22 29 3b 0a 09 65 |eam sock|et");..e|
|00001a90| 78 69 74 28 31 29 3b 0a | 09 7d 0a 0a 0a 20 20 20 |xit(1);.|.}... |
|00001aa0| 20 2f 2a 20 4e 61 6d 65 | 20 73 6f 63 6b 65 74 20 | /* Name| socket |
|00001ab0| 75 73 69 6e 67 20 75 73 | 65 72 20 73 75 70 70 6c |using us|er suppl|
|00001ac0| 69 65 64 20 70 6f 72 74 | 20 6e 75 6d 62 65 72 20 |ied port| number |
|00001ad0| 2a 2f 0a 0a 20 20 20 20 | 73 65 72 76 65 72 2e 73 |*/.. |server.s|
|00001ae0| 69 6e 5f 66 61 6d 69 6c | 79 20 3d 20 41 46 5f 49 |in_famil|y = AF_I|
|00001af0| 4e 45 54 3b 0a 20 20 20 | 20 73 65 72 76 65 72 2e |NET;. | server.|
|00001b00| 73 69 6e 5f 61 64 64 72 | 2e 73 5f 61 64 64 72 20 |sin_addr|.s_addr |
|00001b10| 3d 20 49 4e 41 44 44 52 | 5f 41 4e 59 3b 0a 20 20 |= INADDR|_ANY;. |
|00001b20| 20 20 73 65 72 76 65 72 | 2e 73 69 6e 5f 70 6f 72 | server|.sin_por|
|00001b30| 74 20 3d 20 69 6e 73 6f | 63 6b 6e 75 6d 3b 0a 0a |t = inso|cknum;..|
|00001b40| 20 20 20 20 69 66 20 28 | 62 69 6e 64 28 69 6e 73 | if (|bind(ins|
|00001b50| 6f 63 6b 2c 20 26 73 65 | 72 76 65 72 2c 20 73 69 |ock, &se|rver, si|
|00001b60| 7a 65 6f 66 28 73 65 72 | 76 65 72 29 29 29 20 7b |zeof(ser|ver))) {|
|00001b70| 0a 09 70 65 72 72 6f 72 | 28 22 62 69 6e 64 69 6e |..perror|("bindin|
|00001b80| 67 20 70 73 65 75 64 6f | 2d 70 6f 72 74 20 73 74 |g pseudo|-port st|
|00001b90| 72 65 61 6d 20 73 6f 63 | 6b 65 74 22 29 3b 0a 09 |ream soc|ket");..|
|00001ba0| 65 78 69 74 28 31 29 3b | 0a 09 7d 0a 0a 0a 20 20 |exit(1);|..}... |
|00001bb0| 20 20 2f 2a 20 53 74 61 | 72 74 20 61 63 63 65 70 | /* Sta|rt accep|
|00001bc0| 74 69 6e 67 20 63 6f 6e | 6e 65 63 74 69 6f 6e 73 |ting con|nections|
|00001bd0| 20 2a 2f 0a 0a 20 20 20 | 20 6c 69 73 74 65 6e 28 | */.. | listen(|
|00001be0| 69 6e 73 6f 63 6b 2c 20 | 53 4f 4d 41 58 43 4f 4e |insock, |SOMAXCON|
|00001bf0| 4e 29 3b 0a 0a 0a 20 20 | 20 20 2f 2a 20 45 76 65 |N);... | /* Eve|
|00001c00| 72 79 20 63 6f 6e 6e 65 | 63 74 69 6f 6e 20 73 70 |ry conne|ction sp|
|00001c10| 61 77 6e 73 20 61 20 63 | 68 69 6c 64 20 74 6f 20 |awns a c|hild to |
|00001c20| 68 61 6e 64 6c 65 20 74 | 68 65 20 63 6f 6d 6d 75 |handle t|he commu|
|00001c30| 6e 69 63 61 74 69 6f 6e | 20 2a 2f 0a 0a 20 20 20 |nication| */.. |
|00001c40| 20 64 6f 20 7b 0a 09 6d | 73 67 73 6f 63 6b 20 3d | do {..m|sgsock =|
|00001c50| 20 61 63 63 65 70 74 28 | 69 6e 73 6f 63 6b 2c 20 | accept(|insock, |
|00001c60| 30 2c 20 30 29 3b 0a 09 | 69 66 20 28 6d 73 67 73 |0, 0);..|if (msgs|
|00001c70| 6f 63 6b 20 3d 3d 20 2d | 31 29 0a 09 09 70 65 72 |ock == -|1)...per|
|00001c80| 72 6f 72 28 22 61 63 63 | 65 70 74 22 29 3b 0a 09 |ror("acc|ept");..|
|00001c90| 7d 20 77 68 69 6c 65 20 | 28 66 6f 72 6b 28 29 20 |} while |(fork() |
|00001ca0| 21 3d 20 30 29 3b 0a 0a | 0a 20 20 20 20 2f 2a 20 |!= 0);..|. /* |
|00001cb0| 43 6c 6f 73 65 20 6c 69 | 73 74 65 6e 69 6e 67 20 |Close li|stening |
|00001cc0| 70 6f 73 74 20 2d 20 69 | 74 27 73 20 6e 6f 77 20 |post - i|t's now |
|00001cd0| 63 61 6c 6c 65 64 20 22 | 6d 73 67 73 6f 63 6b 22 |called "|msgsock"|
|00001ce0| 20 2a 2f 0a 0a 20 20 20 | 20 63 6c 6f 73 65 28 69 | */.. | close(i|
|00001cf0| 6e 73 6f 63 6b 29 3b 0a | 0a 0a 20 20 20 20 2f 2a |nsock);.|.. /*|
|00001d00| 20 43 72 65 61 74 65 20 | 6f 75 74 70 75 74 20 73 | Create |output s|
|00001d10| 6f 63 6b 65 74 20 74 6f | 20 73 65 72 76 65 72 20 |ocket to| server |
|00001d20| 2a 2f 0a 0a 20 20 20 20 | 6f 75 74 73 6f 63 6b 20 |*/.. |outsock |
|00001d30| 3d 20 73 6f 63 6b 65 74 | 28 41 46 5f 49 4e 45 54 |= socket|(AF_INET|
|00001d40| 2c 20 53 4f 43 4b 5f 53 | 54 52 45 41 4d 2c 20 30 |, SOCK_S|TREAM, 0|
|00001d50| 29 3b 0a 20 20 20 20 69 | 66 20 28 6f 75 74 73 6f |);. i|f (outso|
|00001d60| 63 6b 20 3c 20 30 29 20 | 7b 0a 09 70 65 72 72 6f |ck < 0) |{..perro|
|00001d70| 72 28 22 6f 70 65 6e 69 | 6e 67 20 73 65 72 76 65 |r("openi|ng serve|
|00001d80| 72 20 73 74 72 65 61 6d | 20 73 6f 63 6b 65 74 22 |r stream| socket"|
|00001d90| 29 3b 0a 09 65 78 69 74 | 28 31 29 3b 0a 09 7d 0a |);..exit|(1);..}.|
|00001da0| 0a 0a 20 20 20 20 2f 2a | 20 43 6f 6e 6e 65 63 74 |.. /*| Connect|
|00001db0| 20 73 6f 63 6b 65 74 20 | 75 73 69 6e 67 20 6d 61 | socket |using ma|
|00001dc0| 63 68 69 6e 65 20 26 20 | 70 6f 72 74 20 73 70 65 |chine & |port spe|
|00001dd0| 63 69 66 69 65 64 20 6f | 6e 20 63 6f 6d 6d 61 6e |cified o|n comman|
|00001de0| 64 20 6c 69 6e 65 2e 20 | 2a 2f 0a 0a 20 20 20 20 |d line. |*/.. |
|00001df0| 73 65 72 76 65 72 2e 73 | 69 6e 5f 66 61 6d 69 6c |server.s|in_famil|
|00001e00| 79 20 3d 20 41 46 5f 49 | 4e 45 54 3b 0a 20 20 20 |y = AF_I|NET;. |
|00001e10| 20 68 70 20 3d 20 67 65 | 74 68 6f 73 74 62 79 6e | hp = ge|thostbyn|
|00001e20| 61 6d 65 28 61 72 67 76 | 5b 33 5d 29 3b 0a 20 20 |ame(argv|[3]);. |
|00001e30| 20 20 69 66 20 28 68 70 | 20 3d 3d 20 30 29 20 7b | if (hp| == 0) {|
|00001e40| 0a 09 66 70 72 69 6e 74 | 66 28 73 74 64 65 72 72 |..fprint|f(stderr|
|00001e50| 2c 20 22 25 73 3a 20 75 | 6e 6b 6e 6f 77 6e 20 6d |, "%s: u|nknown m|
|00001e60| 61 63 68 69 6e 65 5c 6e | 22 2c 20 61 72 67 76 5b |achine\n|", argv[|
|00001e70| 33 5d 29 3b 0a 09 65 78 | 69 74 28 32 29 3b 0a 09 |3]);..ex|it(2);..|
|00001e80| 7d 0a 0a 20 20 20 20 62 | 63 6f 70 79 28 68 70 2d |}.. b|copy(hp-|
|00001e90| 3e 68 5f 61 64 64 72 2c | 20 26 73 65 72 76 65 72 |>h_addr,| &server|
|00001ea0| 2e 73 69 6e 5f 61 64 64 | 72 2c 20 68 70 2d 3e 68 |.sin_add|r, hp->h|
|00001eb0| 5f 6c 65 6e 67 74 68 29 | 3b 0a 20 20 20 20 73 65 |_length)|;. se|
|00001ec0| 72 76 65 72 2e 73 69 6e | 5f 70 6f 72 74 20 3d 20 |rver.sin|_port = |
|00001ed0| 68 74 6f 6e 73 28 6f 75 | 74 73 6f 63 6b 6e 75 6d |htons(ou|tsocknum|
|00001ee0| 29 3b 0a 0a 20 20 20 20 | 69 66 20 28 63 6f 6e 6e |);.. |if (conn|
|00001ef0| 65 63 74 28 6f 75 74 73 | 6f 63 6b 2c 20 26 73 65 |ect(outs|ock, &se|
|00001f00| 72 76 65 72 2c 20 73 69 | 7a 65 6f 66 28 73 65 72 |rver, si|zeof(ser|
|00001f10| 76 65 72 29 29 20 3c 20 | 30 29 20 7b 0a 09 70 65 |ver)) < |0) {..pe|
|00001f20| 72 72 6f 72 28 22 63 6f | 6e 6e 65 63 74 69 6e 67 |rror("co|nnecting|
|00001f30| 20 73 65 72 76 65 72 20 | 73 74 72 65 61 6d 20 73 | server |stream s|
|00001f40| 6f 63 6b 65 74 22 29 3b | 0a 09 65 78 69 74 28 31 |ocket");|..exit(1|
|00001f50| 29 3b 0a 09 7d 0a 0a 0a | 20 20 20 20 2f 2a 20 4f |);..}...| /* O|
|00001f60| 70 65 6e 20 74 68 65 20 | 6f 75 74 70 75 74 20 66 |pen the |output f|
|00001f70| 69 6c 65 73 20 2a 2f 0a | 0a 20 20 20 20 73 70 72 |iles */.|. spr|
|00001f80| 69 6e 74 66 28 62 75 66 | 2c 22 25 73 2e 25 64 2e |intf(buf|,"%s.%d.|
|00001f90| 25 64 22 2c 61 72 67 76 | 5b 34 5d 2c 67 65 74 70 |%d",argv|[4],getp|
|00001fa0| 70 69 64 28 29 2c 67 65 | 74 70 69 64 28 29 29 3b |pid(),ge|tpid());|
|00001fb0| 0a 20 20 20 20 69 66 20 | 28 28 6f 75 74 66 69 6c |. if |((outfil|
|00001fc0| 65 31 20 3d 20 6f 70 65 | 6e 28 62 75 66 2c 20 4f |e1 = ope|n(buf, O|
|00001fd0| 5f 54 52 55 4e 43 7c 4f | 5f 57 52 4f 4e 4c 59 7c |_TRUNC|O|_WRONLY||
|00001fe0| 4f 5f 43 52 45 41 54 2c | 20 30 36 34 34 29 29 20 |O_CREAT,| 0644)) |
|00001ff0| 3d 3d 20 2d 31 29 20 7b | 0a 09 66 70 72 69 6e 74 |== -1) {|..fprint|
|00002000| 66 28 73 74 64 65 72 72 | 2c 22 63 61 6e 6e 6f 74 |f(stderr|,"cannot|
|00002010| 20 6f 70 65 6e 20 66 69 | 6c 65 3a 20 25 73 5c 6e | open fi|le: %s\n|
|00002020| 22 2c 62 75 66 29 3b 0a | 09 65 78 69 74 28 31 29 |",buf);.|.exit(1)|
|00002030| 3b 0a 09 7d 0a 0a 20 20 | 20 20 73 70 72 69 6e 74 |;..}.. | sprint|
|00002040| 66 28 62 75 66 2c 22 25 | 73 2e 25 64 2e 25 64 22 |f(buf,"%|s.%d.%d"|
|00002050| 2c 61 72 67 76 5b 35 5d | 2c 67 65 74 70 70 69 64 |,argv[5]|,getppid|
|00002060| 28 29 2c 67 65 74 70 69 | 64 28 29 29 3b 0a 20 20 |(),getpi|d());. |
|00002070| 20 20 69 66 20 28 28 6f | 75 74 66 69 6c 65 32 20 | if ((o|utfile2 |
|00002080| 3d 20 6f 70 65 6e 28 62 | 75 66 2c 20 4f 5f 54 52 |= open(b|uf, O_TR|
|00002090| 55 4e 43 7c 4f 5f 57 52 | 4f 4e 4c 59 7c 4f 5f 43 |UNC|O_WR|ONLY|O_C|
|000020a0| 52 45 41 54 2c 20 30 36 | 34 34 29 29 20 3d 3d 20 |REAT, 06|44)) == |
|000020b0| 2d 31 29 20 7b 0a 09 66 | 70 72 69 6e 74 66 28 73 |-1) {..f|printf(s|
|000020c0| 74 64 65 72 72 2c 22 63 | 61 6e 6e 6f 74 20 6f 70 |tderr,"c|annot op|
|000020d0| 65 6e 20 66 69 6c 65 3a | 20 25 73 5c 6e 22 2c 62 |en file:| %s\n",b|
|000020e0| 75 66 29 3b 0a 09 65 78 | 69 74 28 31 29 3b 0a 09 |uf);..ex|it(1);..|
|000020f0| 7d 0a 0a 20 20 20 20 64 | 6f 20 7b 0a 09 0a 09 2f |}.. d|o {..../|
|00002100| 2a 20 66 69 6e 64 20 6f | 75 74 20 77 68 6f 27 73 |* find o|ut who's|
|00002110| 20 74 61 6c 6b 69 6e 67 | 20 2a 2f 0a 0a 09 46 44 | talking| */...FD|
|00002120| 5f 5a 45 52 4f 28 26 66 | 64 73 65 74 29 3b 0a 09 |_ZERO(&f|dset);..|
|00002130| 46 44 5f 53 45 54 28 6d | 73 67 73 6f 63 6b 2c 20 |FD_SET(m|sgsock, |
|00002140| 26 66 64 73 65 74 29 3b | 0a 09 46 44 5f 53 45 54 |&fdset);|..FD_SET|
|00002150| 28 6f 75 74 73 6f 63 6b | 2c 20 26 66 64 73 65 74 |(outsock|, &fdset|
|00002160| 29 3b 0a 09 69 66 20 28 | 73 65 6c 65 63 74 28 67 |);..if (|select(g|
|00002170| 65 74 64 74 61 62 6c 65 | 73 69 7a 65 28 29 2c 20 |etdtable|size(), |
|00002180| 26 66 64 73 65 74 2c 20 | 30 2c 20 30 2c 20 30 29 |&fdset, |0, 0, 0)|
|00002190| 20 3d 3d 20 2d 31 29 20 | 7b 0a 09 20 20 20 20 70 | == -1) |{.. p|
|000021a0| 65 72 72 6f 72 28 22 73 | 65 6c 65 63 74 22 29 3b |error("s|elect");|
|000021b0| 0a 09 20 20 20 20 65 78 | 69 74 28 31 29 3b 0a 09 |.. ex|it(1);..|
|000021c0| 20 20 20 20 7d 0a 09 62 | 7a 65 72 6f 28 62 75 66 | }..b|zero(buf|
|000021d0| 2c 20 31 30 32 34 29 3b | 0a 0a 09 69 66 20 28 46 |, 1024);|...if (F|
|000021e0| 44 5f 49 53 53 45 54 28 | 6d 73 67 73 6f 63 6b 2c |D_ISSET(|msgsock,|
|000021f0| 20 26 66 64 73 65 74 29 | 20 26 26 20 46 44 5f 49 | &fdset)| && FD_I|
|00002200| 53 53 45 54 28 6f 75 74 | 73 6f 63 6b 2c 20 26 66 |SSET(out|sock, &f|
|00002210| 64 73 65 74 29 29 0a 09 | 20 20 20 20 66 70 72 69 |dset))..| fpri|
|00002220| 6e 74 66 28 73 74 64 65 | 72 72 2c 22 54 77 6f 20 |ntf(stde|rr,"Two |
|00002230| 74 61 6c 6b 65 72 73 20 | 2d 20 6e 6f 20 6c 69 73 |talkers |- no lis|
|00002240| 74 65 6e 65 72 73 5c 6e | 22 29 3b 0a 0a 0a 09 2f |teners\n|");..../|
|00002250| 2a 20 43 6c 69 65 6e 74 | 20 69 73 20 74 61 6c 6b |* Client| is talk|
|00002260| 69 6e 67 20 74 6f 20 73 | 65 72 76 65 72 20 2a 2f |ing to s|erver */|
|00002270| 0a 0a 09 69 66 20 28 46 | 44 5f 49 53 53 45 54 28 |...if (F|D_ISSET(|
|00002280| 6d 73 67 73 6f 63 6b 2c | 20 26 66 64 73 65 74 29 |msgsock,| &fdset)|
|00002290| 29 20 7b 20 0a 09 20 20 | 20 20 69 66 20 28 28 72 |) { .. | if ((r|
|000022a0| 76 61 6c 20 3d 20 72 65 | 61 64 28 6d 73 67 73 6f |val = re|ad(msgso|
|000022b0| 63 6b 2c 20 62 75 66 2c | 20 31 30 32 34 29 29 20 |ck, buf,| 1024)) |
|000022c0| 3c 20 30 29 0a 09 09 70 | 65 72 72 6f 72 28 22 72 |< 0)...p|error("r|
|000022d0| 65 61 64 69 6e 67 20 73 | 74 72 65 61 6d 20 6d 65 |eading s|tream me|
|000022e0| 73 73 61 67 65 22 29 3b | 0a 09 20 20 20 20 69 66 |ssage");|.. if|
|000022f0| 20 28 72 76 61 6c 20 3d | 3d 20 30 29 0a 09 09 66 | (rval =|= 0)...f|
|00002300| 70 72 69 6e 74 66 28 73 | 74 64 65 72 72 2c 22 45 |printf(s|tderr,"E|
|00002310| 6e 64 69 6e 67 20 63 6c | 69 65 6e 74 20 63 6f 6e |nding cl|ient con|
|00002320| 6e 65 63 74 69 6f 6e 5c | 6e 22 29 3b 0a 09 20 20 |nection\|n");.. |
|00002330| 20 20 65 6c 73 65 20 7b | 0a 09 09 77 72 69 74 65 | else {|...write|
|00002340| 28 6f 75 74 66 69 6c 65 | 31 2c 20 62 75 66 2c 20 |(outfile|1, buf, |
|00002350| 72 76 61 6c 29 3b 0a 09 | 09 77 72 69 74 65 28 6f |rval);..|.write(o|
|00002360| 75 74 66 69 6c 65 31 2c | 20 4d 41 52 4b 2c 20 36 |utfile1,| MARK, 6|
|00002370| 29 3b 0a 09 09 69 66 20 | 28 77 72 69 74 65 28 6f |);...if |(write(o|
|00002380| 75 74 73 6f 63 6b 2c 20 | 62 75 66 2c 20 72 76 61 |utsock, |buf, rva|
|00002390| 6c 29 20 3c 20 30 29 0a | 09 09 20 20 20 20 70 65 |l) < 0).|.. pe|
|000023a0| 72 72 6f 72 28 22 77 72 | 69 74 69 6e 67 20 6f 6e |rror("wr|iting on|
|000023b0| 20 6f 75 74 70 75 74 20 | 73 74 72 65 61 6d 20 73 | output |stream s|
|000023c0| 6f 63 6b 65 74 22 29 3b | 0a 09 09 7d 0a 09 20 20 |ocket");|...}.. |
|000023d0| 20 20 7d 0a 0a 09 2f 2a | 20 53 65 72 76 65 72 20 | }.../*| Server |
|000023e0| 69 73 20 74 61 6c 6b 69 | 6e 67 20 74 6f 20 63 6c |is talki|ng to cl|
|000023f0| 69 65 6e 74 20 2a 2f 0a | 0a 09 65 6c 73 65 20 7b |ient */.|..else {|
|00002400| 0a 09 20 20 20 20 69 66 | 20 28 21 20 46 44 5f 49 |.. if| (! FD_I|
|00002410| 53 53 45 54 28 6f 75 74 | 73 6f 63 6b 2c 20 26 66 |SSET(out|sock, &f|
|00002420| 64 73 65 74 29 29 20 7b | 0a 09 09 70 65 72 72 6f |dset)) {|...perro|
|00002430| 72 28 22 77 65 69 72 64 | 20 62 65 68 61 76 69 6f |r("weird| behavio|
|00002440| 72 22 29 3b 0a 09 09 65 | 78 69 74 28 31 29 3b 0a |r");...e|xit(1);.|
|00002450| 09 09 7d 0a 09 20 20 20 | 20 69 66 20 28 28 72 76 |..}.. | if ((rv|
|00002460| 61 6c 20 3d 20 72 65 61 | 64 28 6f 75 74 73 6f 63 |al = rea|d(outsoc|
|00002470| 6b 2c 20 62 75 66 2c 20 | 31 30 32 34 29 29 20 3c |k, buf, |1024)) <|
|00002480| 20 30 29 0a 09 09 70 65 | 72 72 6f 72 28 22 72 65 | 0)...pe|rror("re|
|00002490| 61 64 69 6e 67 20 73 74 | 72 65 61 6d 20 6d 65 73 |ading st|ream mes|
|000024a0| 73 61 67 65 22 29 3b 0a | 09 20 20 20 20 69 66 20 |sage");.|. if |
|000024b0| 28 72 76 61 6c 20 3d 3d | 20 30 29 0a 09 09 66 70 |(rval ==| 0)...fp|
|000024c0| 72 69 6e 74 66 28 73 74 | 64 65 72 72 2c 22 45 6e |rintf(st|derr,"En|
|000024d0| 64 69 6e 67 20 73 65 72 | 76 65 72 20 63 6f 6e 6e |ding ser|ver conn|
|000024e0| 65 63 74 69 6f 6e 5c 6e | 22 29 3b 0a 09 20 20 20 |ection\n|");.. |
|000024f0| 20 65 6c 73 65 20 7b 0a | 09 09 77 72 69 74 65 28 | else {.|..write(|
|00002500| 6f 75 74 66 69 6c 65 32 | 2c 20 62 75 66 2c 20 72 |outfile2|, buf, r|
|00002510| 76 61 6c 29 3b 0a 09 09 | 77 72 69 74 65 28 6f 75 |val);...|write(ou|
|00002520| 74 66 69 6c 65 32 2c 20 | 4d 41 52 4b 2c 20 36 29 |tfile2, |MARK, 6)|
|00002530| 3b 0a 09 09 69 66 20 28 | 77 72 69 74 65 28 6d 73 |;...if (|write(ms|
|00002540| 67 73 6f 63 6b 2c 20 62 | 75 66 2c 20 72 76 61 6c |gsock, b|uf, rval|
|00002550| 29 20 3c 20 30 29 0a 09 | 09 20 20 20 20 70 65 72 |) < 0)..|. per|
|00002560| 72 6f 72 28 22 77 72 69 | 74 69 6e 67 20 6f 6e 20 |ror("wri|ting on |
|00002570| 6f 75 74 70 75 74 20 73 | 74 72 65 61 6d 20 73 6f |output s|tream so|
|00002580| 63 6b 65 74 22 29 3b 0a | 09 09 7d 0a 09 20 20 20 |cket");.|..}.. |
|00002590| 20 7d 0a 09 7d 20 77 68 | 69 6c 65 20 28 72 76 61 | }..} wh|ile (rva|
|000025a0| 6c 20 21 3d 20 30 29 3b | 0a 0a 0a 20 20 20 20 2f |l != 0);|... /|
|000025b0| 2a 20 43 6c 6f 73 65 20 | 75 70 20 73 68 6f 70 20 |* Close |up shop |
|000025c0| 2a 2f 0a 0a 20 20 20 20 | 66 70 72 69 6e 74 66 28 |*/.. |fprintf(|
|000025d0| 73 74 64 65 72 72 2c 20 | 22 43 6c 6f 73 69 6e 67 |stderr, |"Closing|
|000025e0| 20 43 6f 6e 6e 65 63 74 | 69 6f 6e 73 5c 6e 22 29 | Connect|ions\n")|
|000025f0| 3b 0a 20 20 20 20 63 6c | 6f 73 65 28 6d 73 67 73 |;. cl|ose(msgs|
|00002600| 6f 63 6b 29 3b 0a 20 20 | 20 20 63 6c 6f 73 65 28 |ock);. | close(|
|00002610| 6f 75 74 73 6f 63 6b 29 | 3b 0a 20 20 20 20 63 6c |outsock)|;. cl|
|00002620| 6f 73 65 28 6f 75 74 66 | 69 6c 65 31 29 3b 0a 20 |ose(outf|ile1);. |
|00002630| 20 20 20 63 6c 6f 73 65 | 28 6f 75 74 66 69 6c 65 | close|(outfile|
|00002640| 32 29 3b 0a 20 20 20 20 | 7d 0a 53 48 41 52 5f 45 |2);. |}.SHAR_E|
|00002650| 4f 46 0a 66 69 20 23 20 | 65 6e 64 20 6f 66 20 6f |OF.fi # |end of o|
|00002660| 76 65 72 77 72 69 74 69 | 6e 67 20 63 68 65 63 6b |verwriti|ng check|
|00002670| 0a 23 09 45 6e 64 20 6f | 66 20 73 68 65 6c 6c 20 |.#.End o|f shell |
|00002680| 61 72 63 68 69 76 65 0a | 65 78 69 74 20 30 0a 0a |archive.|exit 0..|
|00002690| 0a | |. | |
+--------+-------------------------+-------------------------+--------+--------+