title: python socket programming OSError: [WinError 10038] an operation was attempted on something that is not a socket
body: <p>I am working on this code</p>
  
  <pre><code>from socket import *
  HOST = 'localhost'
  PORT = 21567
  BUFSIZ = 1024
  ADDR = (HOST, PORT)
  serversock = socket(AF_INET, SOCK_STREAM)
  serversock.bind(ADDR)
  serversock.listen(2)
  
  while 1:
      print ("waiting on connection")
      clientsock, addr = serversock.accept()
      print ('connected from:', addr)
      while 1:
          data = clientsock.recv(1024).decode()
          if not data: break 
          clientsock.send(data.encode())
          clientsock.close()
  
  serversock.close()
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>OSError: [WinError 10038] an operation was attempted on something that is not a socket
  </code></pre>