title: Error: Transport endpoint is not connected (Python Sockets)
body: <p>I'm trying to create a simple chat application using sockets in Python (with threads). Application is simple client has to threads one to send data and another to receive. Server has to two threads one to accept client connection and another to broadcast the message. But on running the below code, I'm getting error message</p>
  
  <blockquote>
    <p>Transport endpoint is not connected</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/iWKPq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iWKPq.png" alt="enter image description here"></a></p>
  
  <p>Can anybody tell me why I'm getting this error</p>
  
  <p>Client</p>
  
  <pre><code>import socket, threading
  
  def send():
      msg = raw_input('Me &gt; ')
      cli_sock.send(msg)
  
  def receive():
      data = cli_sock.recv(4096)
      print('&gt; '+ str(data))
  
  if __name__ == "__main__":   
      # socket
      cli_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
      # connect
      HOST = 'localhost'
      PORT = 5028
      cli_sock.connect((HOST, PORT))     
      print('Connected to remote host...')
  
      thread_send = threading.Thread(target = send)
      thread_send.start()
  
      thread_receive = threading.Thread(target = receive)
      thread_receive.start()
  </code></pre>
  
  <p>Server</p>
  
  <pre><code>import socket, threading
  
  def accept_client():
      while True:
          #accept    
          cli_sock, cli_add = ser_sock.accept()
          CONNECTION_LIST.append(cli_sock)
          print('Client (%s, %s) connected' % cli_add)
  
  def broadcast_data():
      while True:
          data = ser_sock.recv(4096)
          for csock in CONNECTION_LIST:
              try:
                  csock.send(data)
              except Exception as x:
                  print(x.message)
                  cli_sock.close()
                  CONNECTION_LIST.remove(cli_sock)
  
  if __name__ == "__main__":    
      CONNECTION_LIST = []
  
      # socket
      ser_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
      # bind
      HOST = 'localhost'
      PORT = 5028
      ser_sock.bind((HOST, PORT))
  
      # listen        
      ser_sock.listen(1)
      print('Chat server started on port : ' + str(PORT))
  
      thread_ac = threading.Thread(target = accept_client)
      thread_ac.start()
  
      thread_bd = threading.Thread(target = broadcast_data)
      thread_bd.start()
  </code></pre>