Utility to open TCP port to listen state
Solution 1
netcat should do what you want. Have it listen on you machine and echo stuff to STDOUT:
nc -4 -k -l -v localhost 1026
when you want it to close when the connection ends, don't use -k
Solution 2
You have
TCP Listen: http://www.allscoop.com/tcp-listen.php
Port Peeker: http://www.linklogger.com/portpeeker.htm
Microsoft's Command-line utility Portqry.exe
Solution 3
Try iperf. There is a version for Windows. You can just run it like iperf -s -p 1234
, and it will listen on port 1234. You can then connect to that port from a remote machine by doing something like:
telnet 192.168.1.1 1234
iperf -c 192.168.1.1 1234
portqry -n 192.168.1.1 -e 1234
You would need to obtain iperf.exe
or portqry.exe
for the last two. iPerf isn't strictly designed for this task, but it's great for troubleshooting connectivity, bandwidth availability, stress testing links, etc.
Solution 4
It looks like this utility will do exactly what you want, even displaying the received data if you like: http://www.drk.com.ar/builder.php
It has a GUI rather than just a command line, an advantage for some.
Solution 5
The netpipes tools faucet and hose have always served me well, simplifying stdin
and stdout
for my programs to use over the network.
Similar to netcat.
Ubuntu description:
The netpipes package makes TCP/IP streams usable in shell scripts. It can also simplify client/server code by allowing the programmer to skip all the tedious programming bits related to sockets and concentrate on writing a filter, or other service.
EXAMPLES
This creates a TCP-IP socket on the local machine bound to port 3000.
example$ faucet 3000 --out --verbose tar -cf - .
Every time some process (from any machine) attempts to connect to port 3000 on this machine the faucet program will fork(2) a process and the child
will exec(2) a
tar -cf - .
Related videos on Youtube
Vic
Updated on September 18, 2022Comments
-
Vic almost 2 years
Is there some basic utility to open a specific network TCP port on my machine?
I need to test how my program deals with ports in the listening state.
-
Diogo over 12 yearsIt works on Windows??? I tried this command here and it was not recognized.
-
cutrightjm over 12 yearsI was going to post this as my answer! =p You can download netcat here: joncraton.org/files/nc111nt.zip It's a pretty old tool, but I think people failed to realize just how useful it can be.
-
cutrightjm over 12 years@Diogo Rocha You know it is a downloaded program, correct?
-
Diogo over 12 yearsI didn't know... It would be nice if the answear post the link to download then...
-
Florenz Kley over 12 years@DiogoRocha - I removed the bogus link to netcat. The official site is at sourceforge. It's part of pretty much every packaging repository out there, so I have not installed in from source for like 10 years in a row.
-
Diogo over 12 yearsSure, no problem.
-
Vic over 12 yearsLooks good, but the antivirus won't allow me to install neither the "regular" nor the "safe" version of nc for windows.
-
Florenz Kley over 12 yearshumor me - since when when does Wireshark actually behave like a service listening on a port? It passively records the traffic.
-
Florenz Kley over 12 years@Vic - time to make friends with your admin, then... or maybe time for that Linux or BSD virtual machine where you find more tools for network programming you ever dreamed of :-)
-
Breakthrough over 12 years@FlorenzKley you're right, it doesn't... I interpreted his question as how to view the network traffic on a certain port though, since wouldn't it be trivial for the O.P. to just run two copies of his program at once on the same port (to see what happens if another program is already listening on the port)?
-
cutrightjm over 12 years@FlorenzKley If you are saying that my link is bogus, you are mistaken.
-
Vic over 12 yearsThanks, but I need it for Windows...
-
Marcos over 12 yearsNot even Cygwin?
-
hoggar almost 9 yearsTCP listen - nice little GUI program without installation! ;-)
-
Vomit IT - Chunky Mess Style almost 7 yearsDoes this tool allow the opening of TCP port on the machine it is running?
-
Patrik Mihalčin almost 7 yearsI'm not aware of that.. it's just a view as the name suggests
-
Mokubai over 6 yearsNote: some malware or firewall security software might flag this file as a virus. Due to what this program can do it may have been included in malware programs but it is not malware itself and as of 2017-10-04 this file is scanned as clean by VirusTotal (marked as "riskware" by only one scanner). See the Community note on the url and the File scan itself
-
sina nazari over 5 yearsPort Peeker, site no longer exists or is not reachable (Jan 2019)
-
nelson.t.cunha over 5 yearsHere you go, InternetArchive's latest snapshot: web.archive.org/web/20180616055542/http://www.linklogger.com/… Some download links are still working.
-
Peter Mortensen about 5 yearsBut the question is/was: "Is there some basic utility to open a specific network TCP port on my machine?". In TCPView you can close a connection, but that is the only thing that can be changed in the system.
-
ImaginaryHuman072889 over 3 yearsTCP listen for the win. netcat was a very complicated installation. TCP listen is one exe that doesn't require any installation.