title: How to send data over tcp to ESP8266 with python?
body: <p>I want to send data from my computer to ESP8266 over TCP. I wanted to do this with python. I programmed ESP with arduino-language with libraries for it, and reciving is simply:</p>
  
  <pre><code>while(client.available()){
      String in = client.readStringUntil('~'); 
      //i use '~' instead of '\n' as end character because i often can't send '\n' from tcp android apps
      ...
  }
  </code></pre>
  
  <p>I use built-in socket library for python, this is how i try to send data:</p>
  
  <pre><code>server_ip = '192.168.1.100'
  server_port = 3000
  soc = socket.socket()
  soc.connect((server_ip, server_port))
  soc.send("mydata")
  </code></pre>
  
  <p>but i'm still getting error "TypeError: a bytes-like object is required, not 'str'". I tried .sendall etc, and sometimes they work, but then my ESP restarts for some reason, maybe encoding? Could someone give me staight path to just send basic string, even with ascii-only characters?</p>