From owner-freebsd-questions@FreeBSD.ORG Tue Apr 26 08:05:57 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 712B716A4CE for ; Tue, 26 Apr 2005 08:05:57 +0000 (GMT) Received: from webmail2.spymac.net (webmail2.spymac.net [195.225.149.202]) by mx1.FreeBSD.org (Postfix) with ESMTP id BC8E543D49 for ; Tue, 26 Apr 2005 08:05:56 +0000 (GMT) (envelope-from shibbsd@spymac.com) Received: from webmail2.spymac.com (localhost [127.0.0.1]) by webmail2.spymac.net (Postfix) with ESMTP id 26F534C05C for ; Tue, 26 Apr 2005 02:05:55 -0600 (MDT) Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: binary Mime-Version: 1.0 From: To: freebsd-questions@freebsd.org X-Mailer: AtMail 4.02 X-Origin: 217.74.64.247 X-Uidl: 1114502755248174216 Date: Tue, 26 Apr 2005 02:05:55 -0600 Message-Id: <20050426080555.26F534C05C@webmail2.spymac.net> Subject: netcat strange behaviour X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: shibbsd@spymac.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2005 08:05:57 -0000 Hi, I recently came across a very stupid behaviour of netcat - the one in base system (/usr/bin/nc in my FreeBSD 5.4-RC3). I just wanted to connect to a POP3 server, authenticate and grab the STAT information, so I issued the following command: printf "USER XXX\nPASS XXX\nSTAT\nQUIT\n" | nc -i 1 110 And what I got on stdout was: +OK +OK +OK ...and nothing more, the command just exited without any error (FIN_WAIT in netstat). The server had interpreted USER and PASS commands, but ignored anything that came later... The error is 100% reproductible, has been observed on a few different FreeBSD 5 machines, and - what is more - does not depend on a POP3 server! I tried a couple of public ISPs. I have also used a range of -i delays without success. I investigated more and ran tcpdump -xx -v dst host , and what I got was: [...omitted...] 08:55:23.196753 IP (tos 0x0, ttl 64, id 145, offset 0, flags [DF], length: 80) mypc.63175 > mypopserver.pop3: P [bad tcp cksum 2f41 (->71d2)!] 0:40(40) ack 36 win 65535 0x0000: 0050 da74 56b1 0011 11c1 fa55 0800 4500 .P.tV......U..E. 0x0010: 0050 0091 4000 4006 0b19 0a01 0ac7 d94a .P..@.@........J 0x0020: 40ec f6c7 006e f760 36fd f3cd 8805 5018 @....n.`6.....P. 0x0030: ffff 2f41 0000 5553 4552 20XX XXXX XXXX ../A..USER.XXXXX 0x0040: XXXX XXXX 0a50 4153 5320 XXXX XXXX XXXX XXXX.PASS.XXXXXX 0x0050: XXXX XX0a 5354 4154 0a51 5549 540a XXX.STAT.QUIT. [...omitted...] And my BIG question is: should netcat send all these POP3 commands in one packet? I thought that separate lines ought to be separated in TCP/IP terms too - and what is more, I wanted a 1 second delay between lines! (-i option). Any suggestions, bug anticipations or maybe networking lectures for me? ;) I just wanted to check mail :P Thanks Kuba