title: python socket hangs on connect
body: <p>I'm trying to make a transparent proxy in python using the socket module. but for some reason it hangs on connect()ing the socket. here is the code i'm using:</p>
  
  <pre><code>from __future__ import division
  import socket
  import struct
  #import mcpackets
  import sys
  import time
  #CUSTOM SETTINGS
  HOST="192.168.178.28"
  PORT=25565
  #END CUSTOM SETTINGS
  
  serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  serversocket.bind(('',25565))
  serversocket.listen(1)
  print "waiting for client, press multiplayer and use 'localhost' as server"
  clientsocket,address=serversocket.accept()
  print "client connected from %s:%d"%address
  serversocket.close()
  print "connecting to '%s:%d'"%(HOST,PORT)
  serversocket=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  print "socket created."
  serversocket.connect((HOST,PORT))#------------------------------ freezes here
  print "socket connected."
  serversocket.settimeout(0)
  clientsocket.settimeout(0)
  print "timeouts set."
  print "now proxying."
  #tdata=[]
  try:
      while(True):
          dat=None
          try:
              dat=clientsocket.recv(4096)
          except socket.timeout:
              pass
  
          if(dat!=None):
              try:
                  serversocket.send(dat)
              except socket.timeout:
                  pass
          #vice versa
          dat=None
          try:
              dat=serversocket.recv(4096)
          except socket.timeout:
              pass
          if(dat!=None):
  
              try:
                  clientsocket.send(dat)
              except socket.timeout:
                  pass
  except:
      clientsocket.close()
      #with open("data.log","w") as fid:
      #    fid.write(''.join(tdata))
      raise
  </code></pre>
  
  <p>the problem doesn't lie in the network as connecting to the server directly works fine. any ideas on what's going wrong?</p>