TCP Networking

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
RonanZero
Citizen
Posts: 90
Joined: Mon Oct 20, 2014 3:33 am

TCP Networking

Post by RonanZero »

Is there any way I can make my multiplayer game use TCP instead of UDP without remaking luasocket in TCP or something weird like that?
while true do end;
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: TCP Networking

Post by I~=Spam »

This might help (BTW I simply googled "luasocket TCP" ;) ).

Tutorial here: http://w3.impa.br/~diego/software/luaso ... ction.html
API Documentation: http://w3.impa.br/~diego/software/luasocket/tcp.html
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
User avatar
RonanZero
Citizen
Posts: 90
Joined: Mon Oct 20, 2014 3:33 am

Re: TCP Networking

Post by RonanZero »

The tutorial makes use of while true do... that completely stops my game and server, why would it ever do that? It's pretty much a useless tutorial. I tried putting the while true do stuff in love.update but that didn't work. Yes I am using Love for the server. No I am not going to change that.
while true do end;
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: TCP Networking

Post by Positive07 »

RonanZero wrote:The tutorial makes use of while true do... that completely stops my game and server, why would it ever do that? It's pretty much a useless tutorial. I tried putting the while true do stuff in love.update but that didn't work. Yes I am using Love for the server. No I am not going to change that.
Well that means you didnt even read the tutorial and have no idea how to use the library because I totally made it work just with that example. So I guess its not the tutorial that is useless but you, the problem you are having is probably due to the timeout and also check if you received something otherwise keep going like nothing happen. THINK dont make people resolve your issues
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
RonanZero
Citizen
Posts: 90
Joined: Mon Oct 20, 2014 3:33 am

Re: TCP Networking

Post by RonanZero »

Positive07 wrote:
RonanZero wrote:The tutorial makes use of while true do... that completely stops my game and server, why would it ever do that? It's pretty much a useless tutorial. I tried putting the while true do stuff in love.update but that didn't work. Yes I am using Love for the server. No I am not going to change that.
Well that means you didnt even read the tutorial and have no idea how to use the library because I totally made it work just with that example. So I guess its not the tutorial that is useless but you, the problem you are having is probably due to the timeout and also check if you received something otherwise keep going like nothing happen. THINK dont make people resolve your issues
the problem im having is due to while true do...
while true do end;
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: TCP Networking

Post by I~=Spam »

RonanZero wrote:
Positive07 wrote:
RonanZero wrote:The tutorial makes use of while true do... that completely stops my game and server, why would it ever do that? It's pretty much a useless tutorial. I tried putting the while true do stuff in love.update but that didn't work. Yes I am using Love for the server. No I am not going to change that.
Well that means you didnt even read the tutorial and have no idea how to use the library because I totally made it work just with that example. So I guess its not the tutorial that is useless but you, the problem you are having is probably due to the timeout and also check if you received something otherwise keep going like nothing happen. THINK dont make people resolve your issues
the problem im having is due to while true do...
I agree somewhat with positive07 here... This is a TUTORIAL it is showing you how to use the functions that the library provides. I think what your actual issue with the tutorial is that you don't know how to keep your game running while running one of the loops. Just run it in another thread. Your problem could also be that you are afraid that it will use 100% of the CPU... if this is what you are thinking this is just plain wrong and shows that you don't understand what the functions do... The functions pause and wait for the operating system to return with the information. This can mean waiting for information to arrive. Read the tutorial and the api hold back from quick judgement until you completely understand what is happening. If the while true do end really was a problem people wouldn't use luasocket and it is widely used so the while true do end probably isn't a problem. Internet messaging requires a different kind of thinking.
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: TCP Networking

Post by bobbyjones »

You do not need the while true do. Love has one at its heart just place it in love.update. When ever you need something to repeat indefinitely place it in update. Just like in this case it uses an infinite loop. Place it in update. Also I think you have to set timeout to zero I think.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: TCP Networking

Post by Positive07 »

He wants us to post a working port on how this is done in LÖVE, but I dont intend to do so, we are not here to code your game you see? We are here to help, you need to do the rest. That tutorial express that this is how you do it when you dont have a main loop, but if you have one you just need to put the content of while true do inside of your main loop (as RonanZero, BobbyJones and I said before, just put that in love.update) then it says that the functions lock until the timeout is met or data is received, so that basically means you have to reduce the timeout in order not to block your game, just set the timeout to 0 as BobbyJones and I said. THATS IT! BUT YOU DIDNT EVEN READ IT!
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: TCP Networking

Post by Kingdaro »

RonanZero wrote:Is there any way I can make my multiplayer game use TCP instead of UDP without remaking luasocket in TCP or something weird like that?
Is there a reason why you can't use UDP? TCP is normally not recommended for use in games, from what I've read. Especially if its real-time. Have you tried using enet?
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest