Alternative for Netcat Utility

Good tool for testing socket connections?

Hercules is fantastic. It's a fully functioning tcp/udp client/server, amazing for debugging sockets. More details on the web site.

What are the advantages and disadvantages of using Nailgun vs netcat to provide fast CLI to a Java application?

My recomendation would be to go now with nailgun and to prove that this kind of solution really has an positive effect of starting time.

If you have confirmed that the bottleneck is the startup time then you may implement a very simple client/server with the advantage to be free to use any comunication program (netcat, wget, curl, perl, etc) and to have full control over the protocol.

How to listen for multiple tcp connection using nc

Simultaneous connections are not possible with netcat. You should use something like ucspi-tcp's tcpserver tool or leverage xinetd since you're on Linux.

See: https://superuser.com/questions/232747/netcat-as-a-multithread-server

Consecutive connections could be handled through a shell script that restarts netcat after it finishes.

Using BusyBox version of netcat for listening tcp port

Here's the manual page for busybox's nc implementation.

The correct syntax is

nc -l -p <port>

The issue is, I think, that your version of busybox is compiled without nc listening capabilities. Indeed there's a config option at build time, NC_SERVER, that needs to be enabled to turn that feature on.

Can you build another nc, perhaps from this version, and copy the binary onto your embedded host? You may need to build a cross-compiler environment.

Windows 7 netcat error: 'nc' is not recognized as an internal or external command

  • download NetCat from here https://eternallybored.org/misc/netcat/
  • unzip it and put is somewhere (eg: in C:)
  • use directly in the command prompt like: c:\netcat-1.11\nc google.com 80
  • optional: add to Environment Variables to be used from any context
    NetCat

Or install Nmap (includes Netcat)

  • for Windows https://nmap.org/dist/nmap-7.30-setup.exe
  • for Mac https://nmap.org/dist/nmap-7.30.dmg

To check whether ncat is installed and working, open up two terminals. In one of them, run ncat -l 9999 then in the other, ncat localhost 9999. Then type something into each terminal and press Enter. You should see the message on the opposite terminal.
Look in this video https://www.youtube.com/watch?time_continue=1&v=qeQ6pKxUp-Q

Netcat implementation in Python

Does it work if you just use nc?

I think you should try something a little simpler:

import socket

def netcat(hostname, port, content):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((hostname, port))
s.sendall(content)
s.shutdown(socket.SHUT_WR)
while 1:
data = s.recv(1024)
if len(data) == 0:
break
print("Received:", repr(data))
print("Connection closed.")
s.close()

I added the shutdown call because maybe your device is waiting for you to say you're done sending data. (That would be a little weird, but it's possible.)



Related Topics



Leave a reply



Submit