[RESOLVED] Dumb Socket Question? (Can only connect remotely)

Ask questions about Arch Linux ARM. Please search before making a new topic.

[RESOLVED] Dumb Socket Question? (Can only connect remotely)

Postby radengr » Thu Aug 11, 2011 5:20 am

As I mentioned in the community section I am using the mochad daemon on my device to control some x10 devices around my house and pick up motion sensor signals. Mochad opens up a socket that is used to interface with the cm15a or cm19a x10 usb interface device.

I can connect to this easily from another computer with the command `nc 192.168.x.x 1099` (with the real ip of the pogoplug obviously). However, on the plug itself `nc localhost 1099` or `nc 127.0.0.1 1099` or even `nc 192.168.x.x 1099` returns immediately. I have never seen this behavior on my other linux machines with mochad. I figure there is some aspect of networking on ArchLinux that I am missing.

$this->bbcode_second_pass_code('', '[root@alarm ~]# ss -arpt4
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 5 *:rmiregistry *:* users:(("mochad",826,8))
LISTEN 0 5 *:mctp *:* users:(("mochad",826,9))
LISTEN 0 5 *:pt2-discover *:* users:(("mochad",826,10))
LISTEN 0 128 *:ssh *:* users:(("sshd",1311,3))
ESTAB 0 0 192.168.2.111:rmiregistry 192.168.2.107:57816 users:(("mochad",826,11))
ESTAB 0 0 192.168.2.111:ssh 192.168.2.107:57823 users:(("sshd",1333,3))
')

I think the Mochad code creates a pretty straightforward socket (from mochad.c):

$this->bbcode_second_pass_code('', ' /**** sockets ****/
listenfd = socket(AF_INET, SOCK_STREAM, 0);
dbprintf("listenfd %d\n", listenfd);
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(SERVER_PORT);

rc = setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval));
dbprintf("setsockopt() %d/%d\n", rc, errno);
rc = bind(listenfd, (struct sockaddr*) &servaddr, sizeof(servaddr));
dbprintf("bind() %d/%d\n", rc, errno);
rc = listen(listenfd, 5);
dbprintf("listen() %d/%d\n", rc, errno);')
radengr
 
Posts: 22
Joined: Sun Aug 07, 2011 2:08 am

Re: Dumb Socket Question? (Can only connect remotely)

Postby igorert » Thu Aug 11, 2011 9:30 pm

It should be easy to check if this is a networking issue.

On one screen, run netcat in listen mode, e.g.,
$this->bbcode_second_pass_code('', 'nc.openbsd -l -k 0.0.0.0 12345')

On another screen, try to connect to it:
$this->bbcode_second_pass_code('', 'nc.openbsd 127.0.0.1 12345')

If you still can't connect, I'd try running tcpdump on the listen port (12345 above) and then looking at the pcap in wireshark to see what's going on.
igorert
 
Posts: 35
Joined: Sun Jun 26, 2011 5:31 pm
Location: aka chalkbag on irc

Re: Dumb Socket Question? (Can only connect remotely)

Postby radengr » Fri Aug 12, 2011 12:34 am

Thank you! Not only did that work, the nc.openbsd command successfully connected to mochad.

Is the plan `nc` command broken?
radengr
 
Posts: 22
Joined: Sun Aug 07, 2011 2:08 am

Re: Dumb Socket Question? (Can only connect remotely)

Postby igorert » Fri Aug 12, 2011 6:10 pm

$this->bbcode_second_pass_quote('radengr', 'I')s the plan `nc` command broken?

Dunno, I never use gnu netcat but it seems to be broken indeed - I can't make it send a single IP packet out no matter what destination IPs/ports I try. For that matter, it doesn't even seem to be trying - strace shows that there are no attempts to even create a socket for the destination...
igorert
 
Posts: 35
Joined: Sun Jun 26, 2011 5:31 pm
Location: aka chalkbag on irc

Re: Dumb Socket Question? (Can only connect remotely)

Postby veganjay » Mon Sep 12, 2011 1:24 pm

Thanks for this thread - I was banging my head against the wall, checking my firewall settings, etc.
For some reason, it looks like GNU netcat is broken. In other words, "nc <host> <port>" does not work.

Switching to openbsd-netcat seems to have done the trick! (pacman -S openbsd-netcat)
veganjay
 
Posts: 1
Joined: Mon Sep 12, 2011 1:20 pm


Return to User Questions

Who is online

Users browsing this forum: No registered users and 6 guests