title: python3 OSError: [Errno 107] Transport endpoint is not connected
body: <p>I try to make a chat on Python3. Here is my code: </p>
  
  <pre><code>import socket
  import threading
  
  print("Server starts working")
  
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  sock.bind(("", 57054))
  sock.listen(2)
  
  conn, addr = sock.accept()
  
  
  def get_message():
      while True:
          data = sock.recv(1024).decode()
          if len(data) != 0:
              print("Some guy: ", data)
  
  
  def send_message():
      while True:
          message = input()
          if len(message) != 0:
              message = str.encode(message)
              sock.send(message)
              print("You: ", message)
  
  
  def run():
      get_message_thread = threading.Thread(target=get_message())
      send_message_thread = threading.Thread(target=send_message())
  
      get_message_thread.daemon = True
      send_message_thread.daemon = True
  
      get_message_thread.start()
      send_message_thread.start()
  
  
  run()
  
  sock.close()
  </code></pre>
  
  <p>But after the execution and sending a message from other client I get an error message:</p>
  
  <pre><code>Server starts working
  Traceback (most recent call last):
    File "/home/ptrknvk/Documents/Study/Python/chat/chat.py", line 40, in &lt;module&gt;
      run()
    File "/home/ptrknvk/Documents/Study/Python/chat/chat.py", line 30, in run
      get_message_thread = threading.Thread(target=get_message())
    File "/home/ptrknvk/Documents/Study/Python/chat/chat.py", line 15, in get_message
      data = sock.recv(1024).decode()
  OSError: [Errno 107] Transport endpoint is not connected
  
  Process finished with exit code 1
  </code></pre>
  
  <p>I've read, that there are some troubles with sock.accept(), but everything's alright here, as I think.</p>