title: Socket 'No route to host' error
body: <p>I have a connection which is behind a restrictive firewall which only allows HTTP(S) access through a proxy (10.10.1.100:9401). The IP address I get is dynamic and the subnet mask is 255.255.255.255 (I know, weird!).</p>
  
  <p>I tried to write a simple Python socket program to connect to the proxy in order to send some HTTP requests:</p>
  
  <pre><code>import socket
  
  s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
  s.connect(( "10.10.1.100", 9401 ))
  s.send("GET /index.html HTTP/1.1\r\nHost: aorotos.com\r\n\r\n")
  d = s.recv(1024)
  print d
  s.close()
  </code></pre>
  
  <p>I get an exception (113, "No route to host") during the connect. Now here is the weird part&mdash;I can browse the web using these same proxy settings, and if check the currently connected sockets via <code>netstat -tna</code> I see an ACTIVE connection to 10.10.1.100:9401. </p>
  
  <p>I tried a simple command like <code>export http_proxy='10.10.1.100:9401' &amp;&amp; wget aorotos.com/index.html</code> and even that works! If I enable the debug option (<code>-d</code>) in wget, I can even get the socket's file descriptor. </p>
  
  <p>I went through the wget source code, and from what I can see it too uses a normal connect statement and does not set any special socket options (I'll go through it more throughly later). I've tried the same code in C, and it too fails. </p>
  
  <p>The routing table provided via <code>route</code> is</p>
  
  <pre><code>Destination Gateway     Genmask     Flags   Metric Ref  Use Iface
  default      *          0.0.0.0       U     0      0     0  gprs0
  </code></pre>
  
  <p>Does anyone have any idea what might be wrong?</p>
  
  <p>EDIT: Currently my IP is 10.16.82.250. And that is all that is there in the <code>route</code> output. If you're interested my external IP is 203.8.8.2. </p>
  
  <p><code>ifconfig gprs0</code> -</p>
  
  <pre><code>gprs0     Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
            inet addr:10.17.221.94  P-t-P:10.17.221.94  Mask:255.255.255.255
            UP POINTOPOINT RUNNING NOARP  MTU:1400  Metric:1
            RX packets:1832 errors:0 dropped:0 overruns:0 frame:0
            TX packets:1844 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:10 
            RX bytes:1878364 (1.7 MiB)  TX bytes:224746 (219.4 KiB)
  </code></pre>
  
  <p>EDIT 2 :
  I landed up installing tcpdump and going through it's manual, and finally installing wireshark ( I'm on my N900 ) only to realize, from the packet dump, that I've been using the port 4901 instead of 9401 in both in C program and the python script! Doh! I blame the small screen and, well, myself. </p>
  
  <p>Is there any way to close this question with a "I'm an idiot" or something? :P
  Sorry for taking up your time! ( I've spent over a week on this. I can't believe I went through most of <code>wget</code>'s source code! )</p>