I have the following python socket client. Which sends a small message to a socket server. In Python2.7 this works without flaw. However in 3.4 I get the following Traceback. Has the implementation changed? Whats the approach I should take to debug?
Traceback (most recent call last):
File "echo-client.py", line 19, in <module>
sockobj.send(line)
TypeError: 'str' does not support the buffer interface
import sys
from socket import *
_server = 'localhost'
_port = 50007
message = ['Hello network world']
if len(sys.argv) > 1:
_server = sys.argv[1]
if len(sys.argv) > 2:
_port = sys.argv[2]
sockobj = socket(AF_INET, SOCK_STREAM)
sockobj.connect((_server, _port))
for line in message:
sockobj.send(line)
data = sockobj.recv(1024)
print('Client received: {}'.format(data))
sockobj.close()