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