The program is using python 2.7 and I'm using google as my browser.
import socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(('0.0.0.0', 80))
server_socket.listen(10)
client_socket, client_address = server_socket.accept()
print 'New client'
req = client_socket.recv(1024)
data = '0123'
client_socket.send(data, len(data))
client_socket.close()
server_socket.close()
When I run the program and enter to the browser http://127.0.0.1:80 it raises the following error: Traceback (most recent call last): File "C:/.../HttpServer.py", line 7, in client_socket.send(data, len(data)) socket.error: [Errno 10045] The attempted operation is not supported for the type of object referenced
I looked here for the error code 10045 but I did not fully understand what I should do.
The error occurs only when len(data) is larger than 5 or if I don't receive data from the client. If len(data) is 1-4 the data is sent as expected, but if it's exactly 5 then no error rises but the fifth char doesn't get sent. The error has never occurred to me on any other ports. Any ideas how to resolve this issue and why does it happen?
Thanks in advance
Don´t enter bytes size
client_socket.send(data, len(data)) # Errno 10045
client_socket.send(data) # Works