**************Two player pong***********

Started by
4 comments, last by hplus0603 19 years, 7 months ago
hi, I'm beginner in the field of directx (game programming). I'm facing problem in implementing PONG game in network. As I posted the message before that my PONG works fine in same computer(in which one window is server and other is client).But as I try to play the game between two machine it's become too slow. What actually I'm doing is as follows:- 1)I'm using TCP. 2)server side:- for loop { a)receive data(size of message from client and message paddle2) b)send data(paddle1 position and ball x,y position) c)rendering(displaying the paddle and ball) } 3)client side:- for loop { a)send data(paddle 2) b)receive data(paddle1 and ball ) c)rendering. Kindly ,help me .
Advertisement
TCP is a relatively slow protocol. But that shouldn't be a problem as you can get TCP to go very fast. Especially on a local network.

http://www.compuware.com/products/devpartner/profiler/default.asp?cid=3019X36&focus=DevPartner&source=Web+%2D+Evaluation+Request&desc=Download+%2D+%27DevPartner+Profiler+Community+Edition%27&offering=DevPartner&sf=1&p=0

DevPartnet Community Profiler is what you want to see where your bottleneck is. Your program will run horribly slow when it's profiling but the results are accurate for how long various things took to complete.

My guess is that you're using blocking sockets which causes Winsock to halt the program while it waits for a message to come in.

You may also be making the mistake of treating TCP like a messaging protocol. e.g. you expect to send and recieve single whole messages at a time instead of a stream of bytes which could be more than one message or an incomplete message.

It's a streaming protocol. Treat it like one and it will do very well for you.

For a 1 v 1 game a peer-peer will probably be better then server/client.. and by the sounds of it thats what you've nearly got.
Roger that, lets run like hell!
thanks a lot,
But here I'm using nonblocking socket.
Select() function.
for sending paddle position and ball position I have
different send and receive function
sorry I did'nt log in
that's why Im
thanking again.
thanks a lot,
But here I'm using nonblocking socket.
Select() function.
for sending paddle position and ball position I have
different send and receive function
Please don't double-post. There was already an answer in your previous post:


http://www.gamedev.net/community/forums/topic.asp?topic_id=265152
.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement