I'm writing a simple server allowing me and my friends to send information to each other.
Currently I've got the client down easy enough, it's all set up and I can communicate with servers. The problem is I can't get the server to work for some reason, I use working examples offline and it just refuses to function. Here's the code:

import socket
HOST = ''
PORT = 8888
SLOTS = 10

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
     s.bind((HOST, PORT))
except:
     print "Failure To BInd"
s.listen(SLOTS)

conn, addr = s.accept()

I get an error saying that in the s.listen(SLOTS) line, an argument wasn't provided.
Any ideas what is happening?

Can you post the whole error message ?

Edit: this is unrelated to the issue, but if you want to run the program several times, it would be good to add

s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

immediately after calling socket.socket().

Edited 4 Months Ago by Gribouillis

I used another version of the code and was able to fix it, I'm posting the code for future use:

import socket

host = ''
port = 50000
slots = 10
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
s.listen(slots)

I'm not exactly sure why this fixed it but it works so I'm not going to complain :D

This question has already been answered. Start a new discussion instead.