title: Python Socket Send Buffer Vs. Str
body: <p>I am trying to get a basic server (copied from Beginning Python) to send a str.</p>
  
  <p>The error:</p>
  
  <pre><code>c.send( "XXX" )
  TypeError: must be bytes or buffer, not str
  </code></pre>
  
  <p>It seems to work when pickling an object. All of the examples I found, seem to be able to send a string no problem.</p>
  
  <p>Any help would be appreciated,</p>
  
  <p>Stephen</p>
  
  <pre><code>import socket  
  import pickle  
  
  s = socket.socket()
  
  host = socket.gethostname()
  
  port = 80
  
  s.bind((host, port))
  
  s.listen(5)
  
  while True:  
      c, addr = s.accept()  
      print( "Got Connection From ", addr )  
      data = pickle.dumps(c)  
      c.send( "XXX" )  
      #c.send(data)  
      c.close()
  </code></pre>