udp or tcp

Blitz3D Forums/Blitz3D Beginners Area/udp or tcp

which one is bettter UDP or TCP and also when i was testing out TCP it was asking for a port number, how do i find out my port numbers
it was set to 8080 but i couldent get my computers to find each other like that

TCP - Controlled stream-like transfer, guarantee'd delivery.
UDP - No delivery control at all and packet based.

Some interesting posts to read:

http://blitzmax.com/Community/posts.php?topic=81852#922028
http://blitzmax.com/Community/posts.php?topic=81738#920881
http://blitzmax.com/Community/posts.php?topic=76325#853773
http://blitzmax.com/Community/posts.php?topic=74970#840454

(hint: Searched Blitz3D-forum for the word "udp")

thanks for the links, I guess from reading those topics that tcp is not worth considering.
one more thing is will this work with lan cable, because i havent manged to get it to sofar(it says cannot connect to server o the second computer)
I figured that was becausee of the port number(8080) but i dont really know why I thought that.
is the port port number 8080 ok? for the lan, or for wifi internet. I really dont get the port numbers =(

ok Ive been looking into the port numbers and i get it a bit more now
for instance if im useing port 80 and i then open internet explorer one of the two will crash, correct?
anything above 1027 is free to use so a number like 8080 should be fine. the problem i was having before must have been a codeing thing on my part.
thanks for the pointers =)
let me know if im wrong on anything

You can bind a program to port 80 and use internet explorer just fine, since IE isn't actually *listening* on port 80 for incoming requests. However, you would run into problems if you try to run a webserver liker IIS or Apache which binds to port 80. (As do some other applications -- for example, I found out the hard way that Skype also binds port 80 by default. apache failed to install for me initially because of that)

If you're curious what ports are in use by your PC, you may want to try running sysinternals TCPView.


thanks for the links, I guess from reading those topics that tcp is not worth considering.



Nope, I'm very sorry if i gave you that impression. It's all up to what you want to do. Your initial question was:


which one is bettter UDP or TCP [...]



And the answer is that they are two different things. To bring an infamous car analogy I'd illustrate it this way:

Which one is better [Korean car with 1.1 litre engine, 60hp] or [Trailer Truck 18-wheeler, 900hp]?

They both have their similarities (like being a means of transport) both they also have huge differences (like 5L/100km vs 30L/100km and 250kg cargo vs. 50000 kg cargo capacity)

Both tcp and udp are viable for gaming, and on the forums/code archives you'll find working examples of both that you can try for yourself and see what you like best. (If you're interested in TCP find some code written by Wings. I remember testing some example by him that I liked, because it worked quite well)

udp is generally faster and better response times but often requires more control code written by the developer.

Hope this helps a bit.

I did a little work using Blitz3D a while back with a modified version of Wings code, the downloadable VB.net front end just modifies a text/ini file that the server & client(s) code refers to - its here:

http://www.blitzbasic.com/Community/posts.php?topic=76772#862906

you will notice the client just uses the loopback address of 127.0.0.1 on port 7056 so that you can run the clients and server on the same computer for development.

hope it is of some use.

Thanks for all the help.
Ive been doing some work with UDP and have a server which players can log onto and then control a cube. they can see the other peoples cubes moveing around. its working really well so Im gunna try and make a real game now(no cubes)

udp is less time intensive, good luck with your approach grindalf.

Hopefully you've read enough of what Mahan posted to know that UDP messages are not guaranteed and not ordered. That is to say that if I send out messages 1,2,3,4 and 5, the client might receive messages 3,1 and 4, in that order. 2 and 5 were lost, and message 3 came before message 1.

@Gabriel, that is a good point, hopefully grindalf has some header information within his UDP messages which will account for this - not too hard to implement data that will combat your suggested potential issues.