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().

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.