Jump to content

  • Log In with Google      Sign In   
  • Create Account


UDP vs. TCP


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 shmaLbus   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 February 2000 - 01:02 PM

i was just wondering what is prefered when writing with sockets fer games (in c/c++). also i have a little sample app that works alright but i was just wondering how everyone else does there apps. just a basic concept or some pseudo code would be alright. i''m just tryin to get some ideas. and can i get the address of incoming data on UDP or even TCP? that would be most helpful. and how can i send a datagram to a specific address? i guess that if i had the address i could change to that, send, then switch back to recieving from any address. i''m new at this type of programming but i''m learning. writing your own HTTP server and stuff is a bit different than making a game out of it heh.

Sponsor:

#2 SiCrane   Moderators   -  Reputation: 9386

Like
Likes
Like

Posted 23 February 2000 - 01:26 PM

UDP vs. TCP is a well discussed topic on this forum. I would suggest looking in the past 90 days for a thread with similar titles. There aren't that many threads in multiplayer programming so it wouldn't be that hard.

When accept()ing an incoming TCP connection you can fill an sockaddr sturcture which will contain the IP address of the client. I believe you can get similar data from a recvfrom() call for UDP.

You send a datagram to a specific address with the sendto() function.

[* This message editted for spelling errors *]

Edited by - SiCrane on 2/23/00 7:51:55 PM

#3 Rogue   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 February 2000 - 01:35 PM

It depends on the type of game you''re writing....

TCP is what is known as a "connection" oriented protocol. It promises to get packets to their destination and in the correct order, so long as the connection is not lost. It''s reliable and easy to use, but best suited to slower paced games. Think board games, puzzle games or turn based strategy.

UDP is known as a "connectionless" protocol. That means you can send a UDP packet to anybody on the Internet without first creating a connection (which is sometimes a security concern). UDP packets can arrive out of order, or even worse, not at all. Sometimes this is what you want, since UDP won''t log jam like TCP will when it tries to resend lost packets. All of the Quake and Unreal games use UDP.

You might want to check out this article by Dan Royer for more details and source code: http://www.flipcode.com/network/


#4 genovov   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 February 2000 - 01:37 PM

SiCrane is right. One of the parameters for a recvfrom call is a pointer to a sockaddr structure. After the call completes, this structure contains the address of the packet''s origin.

- genovov

#5 shmaLbus   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 February 2000 - 02:31 PM

ok thanks, that''s exactly what i needed.
oh jeez, i can''t believe i never even noticed that you could look at older threads. i never saw that drop down box and i''ve been coming here how long?
sorry bout that.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS