Note that there are some explanatory texts on larger screens.

plurals
  1. POPython socket on Windows 7 is not accessible from another machine
    primarykey
    data
    text
    <p>I'm trying to create a Python program that will listen on a socket. I'm using Windows 7 with Python 2.7. Whatever I do, the socket seems to be accessible from the local machine but not from elsewhere on the network.</p> <p>I've got the following code:</p> <pre><code>from werkzeug.wrappers import Request, Response @Request.application def application(request): return Response('Hello World!') if __name__ == '__main__': from werkzeug.serving import run_simple # Using empty string or the machine's real IP address here # gives the same problem run_simple('0.0.0.0', 4000, application) </code></pre> <p>If I connect from the local machine I see the response fine. If I execute</p> <pre><code>$ curl 'http://192.168.1.1:4000/' </code></pre> <p>from another (linux) box on the network, the curl hangs for a long time before timing out. Wireshark shows that I receive a SYN packet to port 4000 but don't see it ACKed.</p> <p>I've tried making sure packets to this port are allowed through the firewall (the fact that I see the SYNs in Wireshark suggests this is not the problem). I've tried setting Python to run as administrator (and I've checked that <code>ctypes.windll.shell32.IsUserAnAdmin()</code> returns true). This isn't just Werkzeug, I've tried with SocketServer from the Python standard library as well.</p> <p>Running Windows Apache on the same port works fine from across the network, which suggests there's no problem with the network or firewall or with my <code>curl</code> request.</p> <p><code>netstat -an</code> shows:</p> <pre><code>TCP 0.0.0.0:4000 0.0.0.0:0 LISTENING </code></pre> <p><strong>Edit</strong>: I've tried with the following minimal code. On the server side (Windows 7):</p> <pre><code>import socket s = socket.socket() s.bind(('', 8080)) s.listen(1) remotesock, addr = s.accept() </code></pre> <p>And on the linux client:</p> <pre><code>import socket s = socket.socket() s.connect('192.168.1.1', 8080) </code></pre> <p>This hangs until timeout, as with the curl.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload