title: fail to start socket client in python
body: <p>I use python 2.7 in windows 7.</p>
  
  <p>I use python to write a socket client. When I start the socket server, it stuck in accept, and then I run the client, but it keeps stuck at accept.</p>
  
  <p>I do not know why the client did not work.
  The server and the client are on the same PC.</p>
  
  <pre><code>    shortcut = QtGui.QShortcut(QtGui.QKeySequence(self.tr("A+D")), self)
      shortcut.activated.connect(lambda: self.ui.start.isEnabled() and 
      self.when_debug())
  
  
  
  @QtCore.Slot()
  def when_debug(self):
      client = Meter_Client("8021")
      time.sleep(2)
      client.connect_to_server_debug()
      client.start_client()
  
  
  
  
  
  
  
  
  
  
  
  class Meter_Client(object):
      def __init__(self, net_port):
       self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
       self.socket_msg_queue = queue.Queue()
       self.socket_thread = None
       self.net_port = int(net_port)
       self.is_exit = False
       self.cur_meter_inst = None
       self.vol_meter_inst = None
  
      def connect_to_server_debug(self):
       SERVER_ADDR = ('127.0.0.1', self.net_port)
       self.socket.connect(SERVER_ADDR)
       self.socket.send("debug")
       print 'debug sent' 
  
  
  
  
  
  
      def start_client(self):
       self.socket_thread = socket_thread(self.socket_msg_queue, 
           self.socket)
       self.socket_thread.start()
  </code></pre>
  
  <p>The server program was written in C#:</p>
  
  <pre><code>   public void SocketServie()
      {
  
          string host = "127.0.0.1";
          int port = 8021;
          socket.SetSocketOption(SocketOptionLevel.Socket, 
           SocketOptionName.ReuseAddress, true);   
          socket.Bind(new IPEndPoint(IPAddress.Parse(host), port));
          socket.Listen(100);  
          Thread SocketThread = new Thread(this.ListenClientConnect);  
          SocketThread.IsBackground = true;
          SocketThread.Start();
  
  
          string host_2 = "127.0.0.1";
          int port_2 = 8024
          socket_2.SetSocketOption(SocketOptionLevel.Socket, 
          SocketOptionName.ReuseAddress, true); 
          socket_2.Bind(new IPEndPoint(IPAddress.Parse(host_2), port_2));
          socket_2.Listen(100);  
          Thread SocketThread_2 = new Thread(this.ListenClientConnect);
          SocketThread_2.IsBackground = true;
          SocketThread_2.Start();
      }
  
  
      private void ListenClientConnect()
      {
  
          while (true)
          {
  
  
              this.clientSocket = socket.Accept();
  
  
              Thread receiveThread = new Thread(new 
              ParameterizedThreadStart(ReceiveMessage));
  
              receiveThread.IsBackground = true;
  
              receiveThread.Start(this);
              Thread.Sleep(1000);
          }
      }
  </code></pre>