socket data sending problem

ollietempleman at ollietempleman at
Thu Jul 4 00:38:39 CEST 2013

im trying to do a simple socket test program for a school project using the socket module, but im having difficulty in sending data between the client and host program.

so far all tutorials and examples have used something along the lines of:

  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  host = socket.gethostname()
  port = 12345
  s.connect((host, port))

and received it on the server end with:

  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  host = ''
  port = 12345
  s.bind((host, port))
  conn, addr = s.accept()
  print ('client is at', addr)
  data = conn.recv(5)

it all works fine, except for when i try to use:


to send data between the client and server, i just get this error message:

  Traceback (most recent call last):
    File "C:/Users/Ollie/Documents/code/chatroom/", line 9, in <module>
  TypeError: 'str' does not support the buffer interface

if anyone can either show me what im doing wrong, what this means and what's causing it, or even better how to fix it it would be greatly appreciated

many thanks Ollie

More information about the Python-list mailing list