Well, I couldn't think of a better word than online for a title, but I meant allowing others on other computers to connect to a server to play a game.

Right now, I need help in planning my "online" game of Go. I'm moderately new to servers and clients (I know how to create them and create a simple echo program), but I need an efficient way to send and receive data from both ends of the players. I tried making a little chat program, but the problem was that the information was not received until after a raw_input() to get user input.

For example, I had something like this inside a while loop:

data = raw_input("Enter something to send: ")
data = client_socket.rcv(1000)
print "Client #2:", data

The problem is that the data won't be received until the program reaches client_socket.rcv(). Also, if the other client hasn't sent any data, there will be nothing to receive, and thus this client won't be able to enter anything else to send.

This is my problem. My question is how I can efficiently send data back and forth between both clients without having this waiting issue. This will come in handy with my game when I send the data of a mini chat room to go along with the game.

Thanks in advance!

Recommended Answers

All 3 Replies

Personally i would use threading (thats the short answer)
As far as how to go about it, you've got a big project on your hands.

Ok, thanks! I was thinking I had to use them, but since they looked confusing, I wanted to make sure I didn't need to use them unless I had to.

Then again, reading the tutorial, I guess it's not that hard :P

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.