A simple port
of 'netcat' (nc) for DOS
Introduction
Netcat (nc) is a utility that can send and receive data using a TCP/IP
socket. It has the ability to open a connection to another machine or
to listen for incoming connections. Input can be entered interactively
through the keyboard or redirected in from a file. Output can appear on
the screen or redirected to a file. Netcat can be used to send large
files or short messages, and it can be called from within batch files
too.
Here is the detailed readme for netcat: nc.txt
Features
- Can translate MS-DOS style newlines (CR/LF) to Unix style newlines (LF)
- Can send/receive newlines using the Telnet NVT standard for use with SMTP, FTP, POP, etc.
- Local echoing can be toggled on and off
- MS-DOS binary and text modes
- High performance when using binary mode and reading from stdin and writing to stdout
- Get status duing a large data transfer by hitting Alt-S
Why use Netcat?
Netcat is like a Swiss Army knife - you can use it to build all sorts
of internet enabled utilities without doing TCP/IP programming. If you
can put your data in files you can use the redirection built into
MS-DOS to have netcat send and receive data for you.
For example, here is a simple text file that contains the commands for an SMTP server to send email:
HELO mail.yourdomain.com
MAIL FROM:<you@yourdomain.com>
RCPT TO:<friend@somewhereelse.com>
DATA
From: You <you@yourdomain.com>
To: Friend <friend@somewhereelse.com>
Subject: Test message using Netcat
DOS rules!
Networking with DOS rules even more!
-Bye!
.
QUIT
Put that in a text file, correct the names and machines, and then use
netcat to send the commands and mail to your outgoing SMTP
server:
nc -target smtp.yourisp.com 25 -telnet_nl -w 10 < mailtest.txt
That will tell netcat to connect to your ISP's SMTP server on port 25
and send the file to it. (The file is redirected from stdin.) You can
pipe the text sent back from the SMTP server to a file to have a record
of the email being sent. (This isn't perfect as it ignores the
SMTP return codes, but for a quick and dirty utility it works fine.)
Another possible use is as a low-budget file transfer program between
two machines when FTP is not available. For example, this command will
setup one machine to listen for an incoming connection and when the
connection is received it will write everything that it gets to
newfile.bin:
nc -listen 2000 -bin > newfile.bin
On another machine you can use netcat to connect to the waiting machine and send a file:
nc -target 192.168.2.10 2000 -bin -verbose < origfile.bin
Assuming the the listening machine is at that address, origfile.bin
will be read on stdin, transferred over the network, and the listening
machine will write it to newfile.bin. It will be an exact copy of
origfile.bin.
These are just two of the uses for netcat ...
Download!
Netcat is included with the other mTCP based applications. They can be
downloaded from the
main mTCP page
here.
Changelog
2010-02-10: A complete rewrite!
- Added -bin option to switch between MS-DOS binary and text modes
- Added -telnet_nl option to send newline characters in Telnet NVT standard
- Correct interpretation of the Enter key in binary, text, and telnet_nl modes
- Added local echoing option
- Added ability to get connection status even when redirecting from stdin
- Added -w option to wait for delayed input from the other side
- Added option to hold a half-closed connection open until you close it manually
Created July 31st, 2008, Last updated February 8th, 2010
(C)opyright Michael B. Brutman, mbbrutman@yahoo.com