sockets and servers for game hosting
-
Hello again everybody. I'm making a network game at the request of a friend of mine and I've run into some trouble. the thing is, in the game-cafe all the computers are networked and i need to send data from one PC to the other. I came onto the solution of using sockets for this, but now I'm in a bit of a complex situation. I need to create the classes for the host computer and the client computer. the client asks for a game while the host listens for connections and accepts them. the problem's are:- 1) When i read the python docs it said that the function socket.bind(address) binds the socket to an address. Is that address on the socket's host or on the client PC? 2) While the socket is listening for connections using the socket.listen(backlog) function, how will it know which connection is from the client PC, so that it can accept that connection? 3) The stupid problem....how exactly do I check the entire network for hosts that are currently listening for connections? I would be REALLY thankful to anyone who can clear this up for me.
-
Hello again everybody. I'm making a network game at the request of a friend of mine and I've run into some trouble. the thing is, in the game-cafe all the computers are networked and i need to send data from one PC to the other. I came onto the solution of using sockets for this, but now I'm in a bit of a complex situation. I need to create the classes for the host computer and the client computer. the client asks for a game while the host listens for connections and accepts them. the problem's are:- 1) When i read the python docs it said that the function socket.bind(address) binds the socket to an address. Is that address on the socket's host or on the client PC? 2) While the socket is listening for connections using the socket.listen(backlog) function, how will it know which connection is from the client PC, so that it can accept that connection? 3) The stupid problem....how exactly do I check the entire network for hosts that are currently listening for connections? I would be REALLY thankful to anyone who can clear this up for me.
Hi, shahab96! It is a good question! Did you find out the solution?
-
Hi, shahab96! It is a good question! Did you find out the solution?
-
Hello again everybody. I'm making a network game at the request of a friend of mine and I've run into some trouble. the thing is, in the game-cafe all the computers are networked and i need to send data from one PC to the other. I came onto the solution of using sockets for this, but now I'm in a bit of a complex situation. I need to create the classes for the host computer and the client computer. the client asks for a game while the host listens for connections and accepts them. the problem's are:- 1) When i read the python docs it said that the function socket.bind(address) binds the socket to an address. Is that address on the socket's host or on the client PC? 2) While the socket is listening for connections using the socket.listen(backlog) function, how will it know which connection is from the client PC, so that it can accept that connection? 3) The stupid problem....how exactly do I check the entire network for hosts that are currently listening for connections? I would be REALLY thankful to anyone who can clear this up for me.
bind is for server to bind to a "well-known" port. listen is the next function that gets executed by the server after binding to the port. you should check out the Richard Stevens Network Programming books (vol 1) for a better explanation. although the information is explained using C, if you are a truly interested in learning; you will eventually learn it like a master. good luck,
David
-
bind is for server to bind to a "well-known" port. listen is the next function that gets executed by the server after binding to the port. you should check out the Richard Stevens Network Programming books (vol 1) for a better explanation. although the information is explained using C, if you are a truly interested in learning; you will eventually learn it like a master. good luck,
David
I actually lost hope on that topic. Well in the months since i posted it i learned how to use sockets in c and java so i think if the python sockets are explained in C i will be able to easily follow on. Even better if the code is actually based on C sockets. (Preferably linux sockets) Thanks David :)