in reply to Socket programming Help

Hi Kelicula,

Your code works for me, and I suspect it's working for you when you test it locally? But on the server, the line LocalHost => '127.0.0.1', causes the server socket to bind to that address (localhost) and listen for local connections only. Try simply removing that line, and the server will listen for connections on any interface (usually represented by 0.0.0.0).

You can check what port and address the server is listening on via the command netstat -nap46 (possibly with a sudo in front). Also, I'd suggest you get to know Wireshark for monitoring what's actually happening on the network and whether the connection attempts from the Internet are reaching your machine.

And by the way, Use strict and warnings!

Update: Another potential problem that you might encounter during testing is the "hairpin NAT" problem, in which your router may not be able to handle the situation where you are trying access its public Internet IP / dynamic DNS hostname from inside the network. In that case one possible solution is that when your clients are inside your network, they need to use the server's internal address (typically 192.168.X.X), and the public Internet IP when outside your network.

One more potential situation is that your ISP may be blocking certain incoming connections, in that case the aforementioned Wireshark should be able to help you - you wouldn't see any incoming connections even if your router is configured correctly.

Hope this helps,
-- Hauke D

Replies are listed 'Best First'.
Re^2: Socket programming Help (updated)
by Kelicula (Novice) on Apr 19, 2016 at 21:42 UTC

    Thank you for your help Hauke, I originally had the address 0.0.0.0 in there, but that didn't work either. The "server" computer is running Windows, but the raspberry's are running Raspbian, and they are NEVER on the same network. I have it set up for testing even that they are on an external network, so I have NEVER seen it work. :-(

    The program running on Windows with ActiveState 64 bit Perl, is running fine ( no warnings or errors, even with strict and warnings on ) but the script on the raspberry's just time's out every time... It never prints "Connected to socket".

    I will try the Wireshark you mentioned see if that gives any insight. Maybe it's just that sockets aren't what we need, Ideally we would want something like Teamviewer or RDP but they don't run on ARM Raspbian without extensive tweaking...

      Hi Kelicula,

      Ok, well two more ideas:

      Do the scripts work when both are run locally on the same Windows machine? (maybe also try running both server+client together on the RPi for good measure)

      Is the Windows firewall configured to allow incoming connections on that port?

      Regards,
      -- Hauke D

      From the Pi: telnet your_servers_external_ip_addr 7777. If that fails to connect, you've got a firewall or NAT issue.