You are not logged in.
I was just performing a quick socket test on a Raspberry Pi using netcat:
nc -l -p 2007
Yet when I try and connect to the socket with netcat I get the following output and netcat immediately closes.
$ nc localhost 2007
----------------------------
Notice: Real hostname for localhost [127.0.0.1] is localhost.localdomain
Notice: Real hostname for localhost [127.0.0.1] is localhost.localdomain
Total received bytes: 0
Total sent bytes: 0
Using netstat I can see the socket gets created
netstat -tulnap | grep 2007
--------------------------
tcp 0 0 0.0.0.0:2007 0.0.0.0:* LISTEN 2369/nc
And if I connect from a different machine on the same network it all works as expected:
$ nc 192.168.2.6 2008 -vv
Warning: Inverse name lookup failed for `192.168.2.6'
192.168.2.6 2008 (conf) open
What on earth could be happening? Is it something to do with the Inverse name lookup failure?
For reference here's the output of ifconfig:
eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:7e:39:0f txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 0 (Local Loopback)
RX packets 18 bytes 1512 (1.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 18 bytes 1512 (1.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.6 netmask 255.255.255.0 broadcast 192.168.2.255
ether e0:46:9a:2b:2c:ca txqueuelen 1000 (Ethernet)
RX packets 47753 bytes 12152129 (11.5 MiB)
RX errors 0 dropped 48362 overruns 0 frame 0
TX packets 37084 bytes 6283782 (5.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Last edited by anthillsocial (2013-10-18 22:22:12)
Offline
I discovered that there's a bug with netcat on ARM architecture:
http://archlinuxarm.org/forum/viewtopic.php?f=9&t=1499
To solve the issue I swapped the gnu version of netcat with the openbsd version and it now works as expected:
sudo pacman -S openbsd-netcat
Offline
Here's a link to the bug which was reported in 2005!
Though the suggested patch doesn't seem to have been incorporated:
http://sourceforge.net/p/netcat/bugs/23
What can be done to fix it?
Offline