Reputation: 26
This is not a duplicate.
I have searched for literally hours to find the answer and no luck so I'm asking here.
I am currently building a chat server using python's socket module. When I run the server, after the client connects and the server says so, I receive an exception:
[WinError 10038] An operation was attempted on something that is not a socket
I have built a drastically reduced server and it works where this server does not. This has confused me as it is doing the same thing nearly line for line.
Simplified:
Upvotes: 1
Views: 12766
Reputation: 230
let me clear a couple of things out for you:
The server side in your case is fine, however, at the client side you need to remove this line:
s.bind(("127.0.0.1",port))
You would generally do something like this for example:
ip = '127.0.0.1'
port = 1234
s.connect((ip, port))
s.send("hello".encode("utf-8"))
while True:
s.send(input().encode("utf-8"))
Upvotes: 2