From owner-man-jp-reviewer@jp.FreeBSD.org Mon Oct 10 16:05:26 2005
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) id j9A75QI48891;
	Mon, 10 Oct 2005 16:05:26 +0900 (JST)
	(envelope-from owner-man-jp-reviewer@jp.FreeBSD.org)
Received: from t-mta3.odn.ne.jp (mfep3.odn.ne.jp [143.90.131.181])
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) with ESMTP/inet id j9A75Qw48886
	for <man-jp-reviewer@jp.FreeBSD.org>; Mon, 10 Oct 2005 16:05:26 +0900 (JST)
	(envelope-from n-kogane@syd.odn.ne.jp)
Received: from kces6.koganemaru.co.jp ([61.201.44.116]) by t-mta3.odn.ne.jp
          with ESMTP
          id <20051010070525746.IJGY.496069.t-mta3.odn.ne.jp@mta3.odn.ne.jp>
          for <man-jp-reviewer@jp.FreeBSD.org>;
          Mon, 10 Oct 2005 16:05:25 +0900
Received: by kces6.koganemaru.co.jp (Postfix, from userid 100)
	id 9EE9EFBD2; Mon, 10 Oct 2005 16:09:41 +0900 (JST)
To: man-jp-reviewer@jp.FreeBSD.org
In-Reply-To: <200510100255.LAA93033@shell.rim.or.jp>
MIME-Version: 1.0 (generated by MimeKit/1.8)
Content-Type: text/plain; charset=ISO-2022-JP
Message-Id: <20051010070941.9EE9EFBD2@kces6.koganemaru.co.jp>
From: n-kogane@syd.odn.ne.jp (Nobuyuki Koganemaru)
Reply-To: man-jp-reviewer@jp.FreeBSD.org
Precedence: list
Date: Mon, 10 Oct 2005 16:09:41 +0900
X-Sequence: man-jp-reviewer 4921
Subject: [man-jp-reviewer 4921] Re: nc.1
Sender: owner-man-jp-reviewer@jp.FreeBSD.org
X-Originator: n-kogane@syd.odn.ne.jp
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+050320

$B>.6b4]$G$9!#(B

>From: kano@na.rim.or.jp
>Date: Mon, 10 Oct 2005 11:55:15 +0900
>
>In message <20051008174728.83285FBDF@kces6.koganemaru.co.jp>
><20051008175226.A6E2DFBDF@kces6.koganemaru.co.jp>
>  n-kogane@syd.odn.ne.jp (Nobuyuki Koganemaru) writes:
>> +$BFC8"@)8B$HMxMQ2DG=@-$r$K$7$?$,$C$F!"(B
>
>$B!V$r!W$r%H%k(B
>
>
>> +$B$9$k$?$a$?$1$K%9%-%c%s$9$Y$-$G$"$k$3$H$rMW5a$7$^$9!#(B
>
>$B$?$1$K(B -> $B$@$1$K(B
>
>> +$B9=C[$9$k$3$H$O$H$G$b4JC1$G$9!#(B
>
>$B$H$G$b(B -> $B$H$F$b(B
>
>> +$B%U%!%$%kE>Aw$r%(%_%e%l!<%H$9$k$?$a$KMF0W$K%-%c%W%A%c(B ($BJa3M(B) $B$^$9!#(B
>
>$B$^$9(B -> $B$5$l$^$9(B

$B$"$j$,$H$&$4$6$$$^$9!#=$@5$r<h$jF~$l$^$7$?!#(B

--- nc.1	Mon Oct 10 15:42:43 2005
+++ /b3/JMAN4/5.4-RELEASE/man1/nc.1	Sun May  8 16:04:02 2005
@@ -1,4 +1,4 @@
-.\"     %OpenBSD: nc.1,v 1.36 2005/01/07 10:11:31 jmc Exp %
+.\"     $OpenBSD: nc.1,v 1.36 2005/01/07 10:11:31 jmc Exp $
 .\"
 .\" Copyright (c) 1996 David Sacerdote
 .\" All rights reserved.
@@ -25,16 +25,15 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" %FreeBSD: src/contrib/netcat/nc.1,v 1.3.2.1 2005/02/13 07:35:07 delphij Exp %
+.\" $FreeBSD: src/contrib/netcat/nc.1,v 1.3.2.1 2005/02/13 07:35:07 delphij Exp $
 .\"
-.\" $FreeBSD$
 .Dd January 30, 2005
 .Dt NC 1
 .Os
-.Sh $BL>>N(B
+.Sh NAME
 .Nm nc
-.Nd $BG$0U$N(B TCP $B$H(B UDP $B$N@\B3$H(B listen ($B@\B3$r<u$1IU$1(B)
-.Sh $B=q<0(B
+.Nd arbitrary TCP and UDP connections and listens
+.Sh SYNOPSIS
 .Nm nc
 .Bk -words
 .Op Fl 46DEdhklnorStUuvz
@@ -51,269 +50,279 @@
 .Op Ar hostname
 .Op Ar port Ns Bq Ar s
 .Ek
-.Sh $B2r@b(B
+.Sh DESCRIPTION
+The
 .Nm
-($B$^$?$O!"(B
+(or
 .Nm netcat )
-$B%f!<%F%#%j%F%#$O!"$[$H$s$I2?$K$G$b(B TCP $B$+(B UDP $B$K4XO"$7$F!"(B
-$B@$3&Cf$G;HMQ$5$l$^$9!#(B
-.\" under the sun = $BB@M[(B[$B@D6u(B]$B$N2<$G!"$3$N@$$G(B[$B$N(B]$B!"E72<$G(B[$B$N(B]$B!"CO5e>e$G(B[$B$N(B]$B!"@$3&Cf$G(B[$B$N(B]
-$B$=$l$O!"(BTCP $B@\B3$r%*!<%W%s$7$F!"(BUDP $B%Q%1%C%H$rAw?.$7$F!"(B
-$BG$0U$N(B TCP $B$H(B UDP $B%]!<%H>e$G(B listen ($B@\B3$r<u$1IU$1(B) $B$7$F!"(B
-$B%]!<%H%9%-%c%s$r$7$F!"$=$7$F(B IPv4 $B$H(B IPv6 $B$NN>J}$r=hM}$9$k$3$H$,$G$-$^$9!#(B
-.Xr telnet 1
-$B$H0[$J$C$F!"(B
+utility is used for just about anything under the sun involving TCP
+or UDP.
+It can open TCP connections, send UDP packets, listen on arbitrary
+TCP and UDP ports, do port scanning, and deal with both IPv4 and
+IPv6.
+Unlike
+.Xr telnet 1 ,
 .Nm
-$B$O!"$&$^$/%9%/%j%W%H$K$7$F!"(B
-$B2?$i$+$r9T$&(B
+scripts nicely, and separates error messages onto standard error instead
+of sending them to standard output, as
 .Xr telnet 1
-$B$N$h$&$K!"%(%i!<%a%C%;!<%8$rI8=`=PNO$KAw$kBe$o$j$KI8=`%(%i!<$KJ,N%$7$^$9!#(B
+does with some.
 .Pp
-$B0lHLE*$JMQES$O<!$r4^$_$^$9(B:
+Common uses include:
 .Pp
 .Bl -bullet -offset indent -compact
 .It
-$BC1=c$J(B TCP $B%W%m%-%7(B
+simple TCP proxies
 .It
-HTTP $B%/%i%$%"%s%H$H%5!<%P$K4p$E$/%7%'%k%9%/%j%W%H(B
+shell-script based HTTP clients and servers
 .It
-$B%M%C%H%o!<%/%G!<%b%s$N%F%9%H(B
+network daemon testing
 .It
+a SOCKS or HTTP ProxyCommand for
 .Xr ssh 1
-($B%;%-%e%"%7%'%k(B) $B$N$?$a$N(B SOCKS $B$^$?$O(B HTTP ProxyCommand
 .It
-$B$=$7$FB?$/!"$5$i$KB?$/(B
+and much, much more
 .El
 .Pp
-$B%*%W%7%g%s$O<!$NDL$j$G$9(B:
+The options are as follows:
 .Bl -tag -width Ds
 .It Fl 4
+Forces
 .Nm
-$B$K6/@)E*$K(B IPv4 $B%"%I%l%9$@$1$r;HMQ$5$;$^$9!#(B
+to use IPv4 addresses only.
 .It Fl 6
+Forces
 .Nm
-$B$K6/@)E*$K(B IPv6 $B%"%I%l%9$@$1$r;HMQ$5$;$^$9!#(B
+to use IPv6 addresses only.
 .It Fl D
-$B%=%1%C%H$G%G%P%C%0$rM-8z$K$7$^$9!#(B
+Enable debugging on the socket.
 .It Fl d
-stdin $B$+$iFI$_9~$`$3$H$r;n$_$^$;$s!#(B
+Do not attempt to read from stdin.
 .It Fl h
+Prints out
 .Nm
-$B%X%k%W$r0u:~$7$^$9!#(B
+help.
 .It Fl E
-$BN>J}8~$X$N(B IPsec ESP $BE>Aw%b!<%I$rM-8z$K$9$k!"(B
-"-e 'in ipsec esp/transport//require' -e 'out ipsec
-esp/transport//require'" $B$NC;=L7A$G$9!#(B
+Shortcut for "-e 'in ipsec esp/transport//require' -e 'out ipsec
+esp/transport//require'", which enables IPsec ESP transport mode in both
+directions.
 .It Fl e
-IPsec $B%5%]!<%H$,MxMQ2DG=$G$"$k$J$i!"$=$l$O(B
-.Xr ipsec_set_policy 3
-$B$G5-=R$5$l$?9=J8$r;HMQ$9$k$3$H$G(B IPsec $B%]%j%7$r;XDj$9$k$3$H$,$G$-$^$9!#(B
-$B$3$N%U%i%0$O!"0lHLE*$K3FJ}8~$G(B 1 $B$D$N%]%j%7$,I,MW$H$5$l$k$h$&$K(B
-2 $B2s$^$G;XDj$9$k$3$H$,$G$-$^$9!#(B
+If IPsec support is available, then one can specify the IPsec policies
+to be used using the syntax described in
+.Xr ipsec_set_policy 3 .
+This flag can be specified up to two times, as typically one policy for
+each direction is needed.
 .It Fl i Ar interval
-$B%F%-%9%HAw<u?.$N9T$N4V$NCY1d;~4V$N4V3V$r;XDj$7$^$9!#(B
-$B$^$?!"J#?t$N%]!<%H$K@\B3$9$k4V$KCY1d;~4V$,@8$8$^$9!#(B
+Specifies a delay time interval between lines of text sent and received.
+Also causes a delay time between connections to multiple ports.
 .It Fl k
+Forces
 .Nm
-$B$K!"8=:_$N@\B3$,=*N;$7$?8e$KJL$N@\B3$r(B listen ($B@\B3$N<u$1IU$1(B)
-$B$7$?$^$^$K$9$k$3$H$r6/@)$7$^$9!#(B
+to stay listening for another connection after its current connection
+is completed.
+It is an error to use this option without the
 .Fl l
-$B%*%W%7%g%s$J$7$G$3$N%*%W%7%g%s$r;HMQ$9$k$H%(%i!<$H$J$j$^$9!#(B
+option.
 .It Fl l
+Used to specify that
 .Nm
-$B$,!"%j%b!<%H%[%9%H$K@\B3$r3+;O$9$k$h$j$`$7$mCe?.@\B3$r(B listen ($B@\B3$N<u$1IU$1(B)
-$B$9$k$Y$-$G$"$k$3$H$r;XDj$9$k$?$a$K;HMQ$5$l$^$9!#(B
+should listen for an incoming connection rather than initiate a
+connection to a remote host.
+It is an error to use this option in conjunction with the
 .Fl p ,
-.Fl s
-$B$^$?$O(B
+.Fl s ,
+or
 .Fl z
-$B%*%W%7%g%s$HF1;~$K$3$N%*%W%7%g%s$r;HMQ$9$l$P%(%i!<$H$J$j$^$9!#(B
-$B$5$i$K!"(B
+options.
+Additionally, any timeouts specified with the
 .Fl w
-$B%*%W%7%g%s$G;XDj$5$l$?$I$s$J%?%$%`%"%&%H$bL5;k$5$l$^$9!#(B
+option are ignored.
 .It Fl n
-$BG$0U$N;XDj$5$l$?%"%I%l%9!"%[%9%HL>$^$?$O%]!<%H$G!"(B
-DNS $B$+%5!<%S%98!:w$O9T$($^$;$s!#(B
+Do not do any DNS or service lookups on any specified addresses,
+hostnames or ports.
 .It Fl o
-.Dq Once-only mode
-($B0lEY$N$_$N%b!<%I(B)$B!#(B
-$B%G%U%)%k%H$G!"(B
-.Nm
-$B$OF~NO$G(B EOF $B>uBV$G=*$o$j$^$;$s$,!"(B
-$B%M%C%H%o!<%/B&$,<WCG$5$l$k$^$GB3$-$^$9!#(B
-.\" closed down = $B<WCG$9$k(B
+.Dq Once-only mode .
+By default,
+.Nm
+does not terminate on EOF condition on input,
+but continues until the network side has been closed down.
+Specifying
 .Fl o
-$B$r;XDj$9$l$P!"(BEOF $B$G=*$o$j$^$9!#(B
+will make it terminate on EOF as well.
 .It Fl p Ar source_port
-$BFC8"@)8B$HMxMQ2DG=@-$K$7$?$,$C$F!"(B
+Specifies the source port
 .Nm
-$B$,;HMQ$9$Y$-$G$"$k%=!<%9(B ($BH/?.85(B) $B%]!<%H$r;XDj$7$^$9!#(B
-.\" subject to = $B!A$r>r7o(B[$BA0Ds(B]$B$H$7$F!"!A$K;YG[$5$l$F!"!A$K=>$C$F!"!A$K@)Ls$5$l$F!"(B
+should use, subject to privilege restrictions and availability.
+It is an error to use this option in conjunction with the
 .Fl l
-$B%*%W%7%g%s$HF1;~$K$3$N%*%W%7%g%s$r;HMQ$9$l$P%(%i!<$H$J$j$^$9!#(B
+option.
 .It Fl r
-$BH/?.85(B ($B;OE@(B) $B$=$7$F(B/$B$^$?$O08@h(B ($B=*E@(B) $B%]!<%H$,!"(B
-$BHO0OFb$GO"B3$7$F$$$k$+!"$^$?$O%7%9%F%`$,$=$l$i$r3d$jEv$F$k=g=x$NBe$o$j$K(B
-$B%i%s%@%`$KA*Br$9$Y$-$G$"$k$3$H$r;XDj$7$^$9!#(B
+Specifies that source and/or destination ports should be chosen randomly
+instead of sequentially within a range or in the order that the system
+assigns them.
 .It Fl S
-RFC 2385 TCP MD5 $B%7%0%M%A%c(B ($B=pL>(B) $B%*%W%7%g%s$rM-8z$K$7$^$9!#(B
+Enables the RFC 2385 TCP MD5 signature option.
 .It Fl s Ar source_ip_address
-$B%Q%1%C%H$rAw?.$9$k$?$a$K;HMQ$5$l$k(B IP $B%$%s%?%U%'!<%9$r;XDj$7$^$9!#(B
+Specifies the IP of the interface which is used to send the packets.
+It is an error to use this option in conjunction with the
 .Fl l
-$B%*%W%7%g%s$HF1;~$K$3$N%*%W%7%g%s$r;HMQ$9$l$P%(%i!<$H$J$j$^$9!#(B
+option.
 .It Fl t
+Causes
 .Nm
-$B$O(B RFC 854 DO $B$H(B WILL $BMW5aBP$7$F(B RFC 854 DON'T $B$H(B WON'T $B1~Ez$rAw$k$h$&$K$7$^$9!#(B
-$B$3$l$G!"(B
+to send RFC 854 DON'T and WON'T responses to RFC 854 DO and WILL requests.
+This makes it possible to use
 .Nm
-$B$,(B telnet $B%;%C%7%g%s$G%9%/%j%W%H$r;HMQ$9$k$3$H$,2DG=$K$J$j$^$9!#(B
+to script telnet sessions.
 .It Fl U
-Unix $B%I%a%$%s%=%1%C%H$r;HMQ$9$k$?$a$K;XDj$7$^$9!#(B
+Specifies to use Unix Domain Sockets.
 .It Fl u
-TCP $B$N%G%U%)%k%H$N%*%W%7%g%s$NBe$o$j$K(B UDP $B$r;HMQ$7$^$9!#(B
+Use UDP instead of the default option of TCP.
 .It Fl v
+Have
 .Nm
-$B$K$h$j>iD9$J=PNO$r@8$8$5$;$^$9!#(B
+give more verbose output.
 .It Fl w Ar timeout
+If a connection and stdin are idle for more than
 .Ar timeout
-$BIC0J>e$K!"@\B3$H(B stdin $B$,%"%$%I%k$G$"$k$J$i!"(B
-$B@\B3$O@E$+$K%/%m!<%:$5$l$^$9!#(B
+seconds, then the connection is silently closed.
+The
 .Fl w
-$B%U%i%0$O(B
+flag has no effect on the
 .Fl l
-$B%*%W%7%g%s$G8z2L$,$"$j$^$;$s!"$9$J$o$A!"(B
+option, i.e.\&
 .Nm
-$B$O(B
+will listen forever for a connection, with or without the
 .Fl w
-$B%U%i%0$N$"$k$J$7$K$+$+$o$i$:!"$$$D$^$G$b@\B3$r(B listen ($B@\B3$r<u$1IU$1(B) $B$7$^$9!#(B
-$B%G%U%)%k%H$G$O%?%$%`%"%&%H$O$"$j$^$;$s!#(B
+flag.
+The default is no timeout.
 .It Fl X Ar proxy_version
-$B%W%m%-%7%5!<%P$HDL?.$9$k$H$-!"(B
+Requests that
 .Nm
-$B$O;XDj$5$l$?%W%m%H%3%k$r;HMQ$9$k$Y$-$G$"$k$H$$$&$3$H$rMW5a$7$^$9!#(B
-$B%5%]!<%H$5$l$F$$$k%W%m%H%3%k$O(B
+should use the specified protocol when talking to the proxy server.
+Supported protocols are
 .Dq 4
 (SOCKS v.4),
 .Dq 5
 (SOCKS v.5)
-$B$H(B
+and
 .Dq connect
-(HTTPS $B%W%m%-%7(B) $B$G$9!#(B
-$B%W%m%H%3%k$,;XDj$5$l$J$$$J$i!"(BSOCKS $B%P!<%8%g%s(B 5 $B$,;HMQ$5$l$^$9!#(B
+(HTTPS proxy).
+If the protocol is not specified, SOCKS version 5 is used.
 .It Xo
 .Fl x Ar proxy_address Ns Oo : Ns
 .Ar port Oc
 .Xc
+Requests that
 .Nm
-$B$,(B
-.Ar proxy_address
-$B$H(B
-.Ar port
-$B$G%W%m%-%7$r;HMQ$7$F(B
+should connect to
 .Ar hostname
-$B$K@\B3$9$Y$-$G$"$k$3$H$rMW5a$7$^$9!#(B
+using a proxy at
+.Ar proxy_address
+and
+.Ar port .
+If
 .Ar port
-$B$,;XDj$5$l$J$$$J$i!"%W%m%-%7%W%m%H%3%k$N$?$a$K$h$/CN$i$l$F$$$k%]!<%H(B
-(SOCKS $B$N$?$a$K(B 1080$B!"(BHTTPS $B$N$?$a$K(B 3128) $B$,;HMQ$5$l$^$9!#(B
+is not specified, the well-known port for the proxy protocol is used (1080
+for SOCKS, 3128 for HTTPS).
 .It Fl z
+Specifies that
 .Nm
-$B$,G$0U$N%G!<%?$r$=$l$i$KAw?.$7$J$$$G%G!<%b%s$r(B listen ($B@\B3$r<u$1IU$1(B)
-$B$9$k$?$a$@$1$K%9%-%c%s$9$Y$-$G$"$k$3$H$rMW5a$7$^$9!#(B
+should just scan for listening daemons, without sending any data to them.
+It is an error to use this option in conjunction with the
 .Fl l
-$B%*%W%7%g%s$HF1;~$K$3$N%*%W%7%g%s$r;HMQ$9$l$P%(%i!<$H$J$j$^$9!#(B
+option.
 .El
 .Pp
 .Ar hostname
-$B$O!"?tCM(B IP $B%"%I%l%9$^$?$O%7%s%\%j%C%/$J%[%9%HL>(B
-.Fl ( n
-$B%*%W%7%g%s$rM?$($J$$>l9g(B) $B$G$"$jF@$^$9!#(B
-$B0lHLE*$K!"%[%9%HL>$O(B
+can be a numerical IP address or a symbolic hostname
+(unless the
+.Fl n
+option is given).
+In general, a hostname must be specified,
+unless the
 .Fl l
-$B%*%W%7%g%s$,M?$($i$l$J$$>l9g(B ($B$=$N>l9g!"%m!<%+%k%[%9%H$,;HMQ$5$l$^$9(B)
-$B;XDj$7$J$1$l$P$J$j$^$;$s!#(B
+option is given
+(in which case the local host is used).
 .Pp
 .Ar port Ns Op Ar s
-$B$OC10l$N@0?t$+HO0O$G$"$jF@$^$9!#(B
-$BHO0O$O7A<0(B nn-mm $B$G$9!#(B
-$B0lHLE*$K!"08@h(B ($B=*E@(B) $B%]!<%H$O(B
+can be single integers or ranges.
+Ranges are in the form nn-mm.
+In general,
+a destination port must be specified,
+unless the
 .Fl U
-$B%*%W%7%g%s$,M?$($i$l$J$$>l9g(B ($B$=$N>l9g!"%=%1%C%H$r;XDj$7$J$1$l$P$J$j$^$;$s(B)
-$B;XDj$7$J$1$l$P$J$j$^$;$s!#(B
-.Sh $B%/%i%$%"%s%H(B/$B%5!<%P%b%G%k(B
-.Nm
-$B$r;HMQ$9$k!"$?$$$X$s4pK\E*$J%/%i%$%"%s%H(B/$B%5!<%P%b%G%k$r(B
-$B9=C[$9$k$3$H$O$H$F$b4JC1$G$9!#(B
-1 $B$DL\$N%3%s%=!<%k$G!"@\B3$N$?$a$KFCDj$N%]!<%H>e$G(B
+option is given
+(in which case a socket must be specified).
+.Sh CLIENT/SERVER MODEL
+It is quite simple to build a very basic client/server model using
+.Nm .
+On one console, start
 .Nm
-$B$N(B listen ($B@\B3$r<u$1IU$1(B) $B$r3+;O$7$^$9!#(B
-$BNc$($P(B:
+listening on a specific port for a connection.
+For example:
 .Pp
 .Dl $ nc -l 1234
 .Pp
 .Nm
-$B$O8=:_!"@\B3$N$?$a$K%]!<%H(B 1234 $B$G(B listen ($B@\B3$r<u$1IU$1(B) $B$5$l$^$9!#(B
-2 $B$DL\$N%3%s%=!<%k(B ($B$^$?$O!"(B2 $B$DL\$N%^%7%s(B) $B$G!"(B
-$B<!$G(B listen ($B@\B3$r<u$1IU$1(B) $B$5$l$k%^%7%s$H%]!<%H$K@\B3$7$^$9!#(B
+is now listening on port 1234 for a connection.
+On a second console
+.Pq or a second machine ,
+connect to the machine and port being listened on:
 .Pp
 .Dl $ nc 127.0.0.1 1234
 .Pp
-$B8=:_!"%]!<%H$N4V$K@\B3$,$"$k$Y$-$G$9!#(B
-2 $B$DL\$N%3%s%=!<%k$G%?%$%W$5$l$?$b$N$O:G=i$N$b$N$KO"7k$5$l$^$9!"(B
-$B$=$7$F5U$b$^$?F1MM$G$9!#(B
-$B@\B3$,%;%C%H%"%C%W$5$l$?8e$K!"(B
-.Nm
-$B$O!"$I$A$iB&$,(B
-.Sq $B%5!<%P(B
-$B$H$7$F;HMQ$5$l$F$$$k$+!"$=$7$F(B
-$B$I$A$iB&$,(B
-.Sq $B%/%i%$%"%s%H(B
-$B$H$7$F;HMQ$5$l$F$$$k$+$rK\Ev$K5$$K$7$^$;$s!#(B
-$B@\B3$O!"(B
+There should now be a connection between the ports.
+Anything typed at the second console will be concatenated to the first,
+and vice-versa.
+After the connection has been set up,
+.Nm
+does not really care which side is being used as a
+.Sq server
+and which side is being used as a
+.Sq client .
+The connection may be terminated using an
 .Dv EOF
-.Pq Sq ^D
-$B$r;HMQ$7$F=*N;$5$l$^$9!#(B
-.Sh $B%G!<%?E>Aw(B
-$BA0$N%;%/%7%g%s$NNc$O4pK\E*%G!<%?E>Aw%b%G%k$r9=C[$9$k$?$a$K(B
-$B3HD%$9$k$3$H$,$G$-$^$9!#(B
-$B@\B3$N0l$D$NC<$X$NF~NO$5$l$?G$0U$N>pJs$O(B
-$BB>$NC<$K=PNO$5$l!"$=$7$FF~NO$H=PNO$O(B
-$B%U%!%$%kE>Aw$r%(%_%e%l!<%H$9$k$?$a$KMF0W$K%-%c%W%A%c(B ($BJa3M(B) $B$5$l$^$9!#(B
+.Pq Sq ^D .
+.Sh DATA TRANSFER
+The example in the previous section can be expanded to build a
+basic data transfer model.
+Any information input into one end of the connection will be output
+to the other end, and input and output can be easily captured in order to
+emulate file transfer.
 .Pp
-$B%U%!%$%kCf$K%-%c%W%A%c(B ($BJa3M(B) $B$5$l$?=PNO$G(B
-$BFCDj$N%]!<%H$G(B listen ($B@\B3$r<u$1IU$1(B) $B$9$k$?$a$K(B
+Start by using
 .Nm
-$B$r;HMQ$9$k$3$H$K$h$C$F!"3+;O$7$^$9!#(B
+to listen on a specific port, with output captured into a file:
 .Pp
 .Dl $ nc -l 1234 \*(Gt filename.out
 .Pp
-2 $B$DL\$N%^%7%s$r;HMQ$7$F!"E>Aw$5$l$k%U%!%$%k$r6!5k$7$F!"(B
-listen ($B@\B3$r<u$1IU$1(B) $B$9$k(B
+Using a second machine, connect to the listening
 .Nm
-$B%W%m%;%9$K@\B3$7$^$9(B:
+process, feeding it the file which is to be transferred:
 .Pp
 .Dl $ nc host.example.com 1234 \*(Lt filename.in
 .Pp
-$B%U%!%$%k$,E>Aw$5$l$?8e$K!"@\B3$O<+F0E*$K%/%m!<%:$5$l$^$9!#(B
-.Sh $B%5!<%P$H$NBPOC(B
-$B%f!<%6%$%s%?%U%'!<%9$rDL$7$F$h$j$`$7$m(B
-.Dq $B<jF0$G(B
-$B%5!<%P$HDL?.$9$k$3$H$O;~!9Lr$KN)$A$^$9!#(B
-$B%/%i%$%"%s%H$K$h$C$FH/9T$5$l$?%3%^%s%I$K1~Ez$7$F$I$s$J%G!<%?$,(B
-$B%5!<%P$KAw?.$5$l$F$$$k$+$r3NG'$9$kI,MW$,$"$k$+$b$7$l$J$$$H$-$K!"(B
-$B%H%i%V%k%7%e!<%F%#%s%0(B ($B>c32E@8!(B) $B$G=u$1$H$J$j$^$9!#(B
-$BNc$($P!"%&%'%V%5%$%H$N%[!<%`%Z!<%8$r8!:w$9$k$?$a$K(B:
+After the file has been transferred, the connection will close automatically.
+.Sh TALKING TO SERVERS
+It is sometimes useful to talk to servers
+.Dq by hand
+rather than through a user interface.
+It can aid in troubleshooting,
+when it might be necessary to verify what data a server is sending
+in response to commands issued by the client.
+For example, to retrieve the home page of a web site:
 .Pp
 .Dl $ echo \&"GET\&" | nc host.example.com 80
 .Pp
-$B$^$?!"$3$l$O%&%'%V%5!<%P$K$h$C$FAw$i$l$?%X%C%@$rI=<($9$k$3$H$K(B
-$BCm0U$7$F$/$@$5$$!#(B
-$BI,MW$J$i!"(B
+Note that this also displays the headers sent by the web server.
+They can be filtered, using a tool such as
 .Xr sed 1 ,
-$B$J$I$N%D!<%k$r;HMQ$7$F!"$=$l$i$r%U%#%k%?$9$k$3$H$,$G$-$^$9!#(B
+if necessary.
 .Pp
-$B%f!<%6$,!"%5!<%P$K$h$C$FMW5a$5$l$?MW5a(B ($B%j%/%(%9%H(B) $B$N7A<0$rCN$C$F$$$k$H$-!"(B
-$B$h$jJ#;($JNc$r9=C[$9$k$3$H$,$G$-$^$9!#(B
-$BJL$NNc$H$7$F!"%a!<%k$O<!$r;HMQ$7$F(B SMTP $B%5!<%P$KEj9F$G$-$^$9(B:
+More complicated examples can be built up when the user knows the format
+of requests required by the server.
+As another example, an email may be submitted to an SMTP server using:
 .Bd -literal -offset indent
 $ nc localhost 25 \*(Lt\*(Lt EOF
 HELO host.example.com
@@ -325,90 +334,82 @@
 QUIT
 EOF
 .Ed
-.Sh $B%]!<%H%9%-%c%s(B
-$B%?!<%2%C%H%^%7%s>e$G$I$N%]!<%H$,%*!<%W%s$5$l!"%5!<%S%9$r<B9T$7$F$$$k$+$r(B
-$BCN$k$?$a$KLr$KN)$A$^$9!#(B
+.Sh PORT SCANNING
+It may be useful to know which ports are open and running services on
+a target machine.
+The
 .Fl z
-$B%U%i%0$O%*!<%W%s%]!<%H$rJs9p$9$k$?$a$K(B
-.Fl v
-.Pq $B>iD9(B
-$B%U%i%0$H6&$K@\B3$r3+;O$7$J$$(B
+flag can be used to tell
 .Nm
-$B$KEA$($k$?$a$K;HMQ$9$k$3$H$,$G$-$^$9!#(B
-$BNc$($P(B:
+not to initiate a connection,
+together with the
+.Fl v
+.Pq verbose
+flag,
+to report open ports.
+For example:
 .Bd -literal -offset indent
 $ nc -vz host.example.com 20-30
 Connection to host.example.com 22 port [tcp/ssh] succeeded!
 Connection to host.example.com 25 port [tcp/smtp] succeeded!
 .Ed
 .Pp
-$B%]!<%HHO0O$O!"%]!<%H(B 20 \- 30 $B$X$N8!:w$r@)8B$9$k$?$a$K;XDj$5$l$^$9!#(B
+The port range was specified to limit the search to ports 20 \- 30.
 .Pp
-$BBe$o$j$K!"$=$l$O!"$I$N%5!<%P%=%U%H%&%'%"$,<B9T$7$F$$$k$+!"$=$7$F!"(B
-$B$I$N%P!<%8%g%s$+$rCN$k$?$a$KLr$KN)$D$+$b$7$l$^$;$s!#(B
-$B$3$N>pJs$O$"$$$5$D%P%J!<$NCf$K$7$P$7$P4^$^$l$F$$$^$9!#(B
-$B$3$l$i$r8!:w$9$k$?$a$K!":G=i$K@\B3$r3NN)$9$kI,MW$,$"$j!"<!$K!"(B
-$B%P%J!<$,8!:w$5$l$?;~$K!"@\B3$r@Z$kI,MW$,$"$j$^$9!#(B
+Alternatively, it might be useful to know which server software
+is running, and which versions.
+This information is often contained within the greeting banners.
+In order to retrieve these, it is necessary to first make a connection,
+and then break the connection when the banner has been retrieved.
+This can be accomplished by specifying a small timeout with the
 .Fl w
-$B%U%i%0$G>.$5$$%?%$%`%"%&%H$r;XDj$9$k$3$H$K$h$C$F!"(B
-$B$^$?$O62$i$/%5!<%P$K(B
+flag, or perhaps by issuing a
 .Qq Dv QUIT
-$B%3%^%s%I$rH/9T$9$k$3$H$K$h$C$F!"$3$l$rC#@.$9$k$3$H$,$G$-$^$9(B:
+command to the server:
 .Bd -literal -offset indent
 $ echo "QUIT" | nc host.example.com 20-30
 SSH-1.99-OpenSSH_3.6.1p2
 Protocol mismatch.
 220 host.example.com IMS SMTP Receiver Version 0.84 Ready
 .Ed
-.Sh $B;HMQNc(B
-$B%=!<%9%]!<%H$H$7$F%]!<%H(B 31337 $B$r;HMQ$7!"(B5 $BIC$N%?%$%`%"%&%H$G(B
-$B%[%9%HL>$N%]!<%H(B 42 $B$X$N(B TCP $B@\B3$r%*!<%W%s$7$^$9(B:
+.Sh EXAMPLES
+Open a TCP connection to port 42 of hostname, using port 31337 as
+the source port, with a timeout of 5 seconds:
 .Pp
 .Dl $ nc -p 31337 -w 5 hostname 42
 .Pp
-$B%[%9%HL>$N%]!<%H(B 53 $B$X$N(B UDP $B@\B3$r%*!<%W%s$7$^$9(B:
+Open a UDP connection to port 53 of hostname:
 .Pp
 .Dl $ nc -u hostname 53
 .Pp
-$B@\B3$N%m!<%+%k$NC<$N(B IP $B$H$7$F(B
-10.1.2.3 $B$r;HMQ$7$F(B example.host $B$N(B $B%]!<%H(B 42 $B$X$N(B TCP $B@\B3$r%*!<%W%s$7$^$9(B:
-.\" .It Li "nc -E example.host 42"
-.Pp
-.Dl $ nc -E example.host 42
-.Pp
-.\" $B86J8(B: .It Li "nc -E ... $B$O(B .Pp<$B2~9T(B>.Dl $nc -E .. <$B2~9T(B>.Pp $B$N8m$j!#(B
-$BCe?.$HH/?.$N%H%i%U%#%C%/$N$?$a$N(B IPsec ESP $B$r;HMQ$7$F(B example.host $B$N(B
-$B%]!<%H(B 42 $B$X$N(B TCP $B@\B3$r%*!<%W%s$7$^$9!#(B
-.\" .It Li "nc -e 'out ipsec esp/transport//require' example.host 42"
-.Pp
-.Dl $ nc -e 'out ipsec esp/transport//require' example.host 42
-.Pp
-.\" $B86J8(B: .It Li "nc -e ... $B$O(B .Pp<$B2~9T(B>.Dl $nc -e .. <$B2~9T(B>.Pp $B$N8m$j!#(B
-$BH/?.%H%i%U%#%C%/$N$_$N$?$a$K(B IPsec ESP $B$r;HMQ$7$F(B example.host $B$N(B
-$B%]!<%H(B 42 $B$X$N(B TCP $B@\B3$r%*!<%W%s$7$^$9!#(B
+Open a TCP connection to port 42 of example.host using 10.1.2.3 as the
+IP for the local end of the connection:
+.It Li "nc -E example.host 42"
+Open a TCP connection to port 42 of example.host using IPsec ESP for
+incoming and outgoing traffic.
+.It Li "nc -e 'out ipsec esp/transport//require' example.host 42"
+Open a TCP connection to port 42 of example.host using IPsec ESP for
+outgoing traffic only.
 .Pp
 .Dl $ nc -s 10.1.2.3 example.host 42
 .Pp
-example.host $B$N%]!<%H(B 20-30 $B$X$N(B UDP $B%Q%1%C%H$rAw?.$7!"(B
-3 $BIC8e$K(B ICMP $B%Q%1%C%H$H6&$K1~Ez$5$l$?$b$N$rJs9p$7$^$9(B:
-$BLuCm(B: example.host $B$O(B hostname $B$N8m$j$+(B?
+Send UDP packets to ports 20-30 of example.host, and report which ones
+responded with an ICMP packet after three seconds:
 .Pp
 .Dl $ nc -uvz -w 3 hostname 20-30
 .Pp
-Unix $B%I%a%$%s%=%1%C%H$r:n@.$7$F!"(Blisten ($B@\B3$r<u$1IU$1(B) $B$7$^$9(B:
+Create and listen on a Unix Domain Socket:
 .Pp
 .Dl $ nc -lU /var/tmp/dsocket
 .Pp
-10.2.3.4$B!"%]!<%H(B 8080 $B$G(B HTTP $B%W%m%-%7$rDL$7$F(B
-$B%[%9%HL>$N%]!<%H(B 42 $B$X@\B3$7$^$9(B:
+Connect to port 42 of hostname via an HTTP proxy at 10.2.3.4, port 8080:
 .Pp
 .Dl $ nc -x10.2.3.4:8080 -Xconnect hostname 42
-.Sh $B4XO"9`L\(B
+.Sh SEE ALSO
 .Xr cat 1
-.Sh $B:n<T(B
-$B%*%j%8%J%k$N<BAu$O(B *Hobbit*
-.Aq hobbit@avian.org
-$B$K$h$j$^$9!#(B
+.Sh AUTHORS
+Original implementation by *Hobbit*
+.Aq hobbit@avian.org .
 .br
-.An Eric Jackson Aq ericj@monkey.org
-$B$K$h$C$F(B IPv6 $B%5%]!<%H$N$?$a$K=q$-D>$5$l$^$7$?!#(B
+Rewritten with IPv6 support by
+.An Eric Jackson Aq ericj@monkey.org .

--
($BM-(B)$B>.6b4]%3%s%T%e!<%?%(%s%8%K%"%j%s%0%5!<%S%9(B ($BJ!2,8)BgLn>k;T(B)
	$B>.6b4](B $B?.9,(B (Nobuyuki Koganemaru)
E-Mail: n-kogane@syd.odn.ne.jp
E-Mail: kogane@jp.FreeBSD.org
E-Mail: kogane@koganemaru.co.jp
URL: http://www.koganemaru.co.jp
