hi, i'm trying to implement a server that adds a time stamp to incoming text form a client.
the server's code is (but doesn't seem to have the problem as demoed by the error below: from socket import * from time import ctime HOST = '' PORT = 21567 BUFSIZ = 1024 ADDR =(HOST, PORT) tcpSerSock = socket(AF_INET, SOCK_STREAM) tcpSerSock.bind(ADDR) tcpSerSock.listen(5) while True: print('waiting for connection ...') tcpCliSock, addr =tcpSerSock.accept() print('...connected from: ', addr) while True: data = tcpCliSock.recv(BUFSIZ) if not data: break tcpCliSock.send('[{}] {}'.format(bytes(ctime(), 'utf-8'),data)) tcpCliSock.close() tcpSerSock.close() the client's code is: from socket import * HOST = 'localhost' PORT = 21567 BUFSIZ = 1024 ADDR =(HOST, PORT) tcpCliSock = socket(AF_INET, SOCK_STREAM) tcpCliSock.bind(ADDR) while True: data=input('> ') if not data: break tcpCliSock.send(data) data = tcpCliSock.recv(BUFSIZ) if not data: break print(data.decode('utf-8')) tcpCliSock.close() the problem is i get the following error when i enter some text: Traceback (most recent call last): File "C:\Python32\tsTclnt3.py", line 17, in <module> tcpCliSock.send(data) TypeError: 'str' does not support the buffer interface can you help?
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor