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 | |
by haukex (Archbishop) on Apr 19, 2016 at 22:01 UTC | |
by stevieb (Canon) on Apr 19, 2016 at 22:08 UTC |