TCP peer to peer

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Luke100000
Party member
Posts: 232
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria
Contact:

TCP peer to peer

Post by Luke100000 »

Hello!

I want to add multiplayer to my games, using TCP and a peer to peer system to avoid servers. I'm using a database to store the IP of the players. Works fine... until I try to connect one client to another one. No incoming connections allowed... So the only way to do this is using a server, right? Where can I get a ultra cheap (or free) server which only sends and receive data to/from the clients? Or is there another way?

Thanks!
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: TCP peer to peer

Post by ivan »

A lot of action pvp games use UDP since it's lighter/faster.
Sure you should be able to make direct connections between players without the need of a server.
Having a server script is useful for enforcing the game logic (preventing client-side cheating/errors) and for lobbies.
You can use free hosting with php for testing this but when you have a lot of players it's a non trivial issue.
User avatar
Luke100000
Party member
Posts: 232
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria
Contact:

Re: TCP peer to peer

Post by Luke100000 »

ivan wrote:A lot of action pvp games use UDP since it's lighter/faster.
Sure you should be able to make direct connections between players without the need of a server.
Having a server script is useful for enforcing the game logic (preventing client-side cheating/errors) and for lobbies.
You can use free hosting with php for testing this but when you have a lot of players it's a non trivial issue.
If the game runs local it works, but not online.
User avatar
Luke100000
Party member
Posts: 232
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria
Contact:

Re: TCP peer to peer

Post by Luke100000 »

Does anyone know a free hosting for a small (php) server?
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: TCP peer to peer

Post by zorg »

Luke100000 wrote:
ivan wrote:A lot of action pvp games use UDP since it's lighter/faster.
Sure you should be able to make direct connections between players without the need of a server.
Having a server script is useful for enforcing the game logic (preventing client-side cheating/errors) and for lobbies.
You can use free hosting with php for testing this but when you have a lot of players it's a non trivial issue.
If the game runs local it works, but not online.
It depends on a lot of things, like router and firewall settings, but i know that UDP/Direct Connections also work online as well. Many times, it's not the code that's the problem, but the network configuration.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
TheOdyssey
Citizen
Posts: 52
Joined: Mon Jul 13, 2015 4:29 pm
Location: Turn Around...

Re: TCP peer to peer

Post by TheOdyssey »

Luke100000 wrote:Does anyone know a free hosting for a small (php) server?
Most you need to pay for. And if you don't need to pay I would be a bit sketchy about it. However, you can just host your own and then proceed to Port Foward your router. This has always worked for me but I haven't tried it with Love2D yet. Good luck :awesome:
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: TCP peer to peer

Post by Nixola »

I've used Altervista in the past, before using a friend's VPS and then buying my own (and, incidentally, switching to a Lua webserver I wrote because I can't make heads or tails of PHP)
You can host a website there as well; you get 1GB of space, 30 GB of bandwidth, PHP5, a MySQL5 database with no more than 20'000 queries per hour, PHPMyAdmin, FTP access, and even an ad system just in case you'd like to try and earn something; you can get more space, more bandwidth and unlimited queries by buying them or using "AlterCents" (ads generate both money and that currency).
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: TCP peer to peer

Post by T-Bone »

The thing is, most people's firewalls prevent random incoming packets. This is regardless of UDP or TCP. If you don't have any budget to speak of, I'd suggest doing a Minecraft: Just distribute the server software and let people set up their own servers. For playing over LAN, it'll be easy, and it gives people a chance to test the game. If it's good, some people will bother to set up servers that can be reached online.
User avatar
TheOdyssey
Citizen
Posts: 52
Joined: Mon Jul 13, 2015 4:29 pm
Location: Turn Around...

Re: TCP peer to peer

Post by TheOdyssey »

T-Bone wrote:The thing is, most people's firewalls prevent random incoming packets. This is regardless of UDP or TCP. If you don't have any budget to speak of, I'd suggest doing a Minecraft: Just distribute the server software and let people set up their own servers. For playing over LAN, it'll be easy, and it gives people a chance to test the game. If it's good, some people will bother to set up servers that can be reached online.
Probably the best choice. But people could just take down their firewalls for testing, or, better yet Windows does allow you to chose which programs can pass the firewall. I don't know for sure but OSX and some Linux Distros should allow it as well.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: TCP peer to peer

Post by s-ol »

TheOdyssey wrote:
T-Bone wrote:The thing is, most people's firewalls prevent random incoming packets. This is regardless of UDP or TCP. If you don't have any budget to speak of, I'd suggest doing a Minecraft: Just distribute the server software and let people set up their own servers. For playing over LAN, it'll be easy, and it gives people a chance to test the game. If it's good, some people will bother to set up servers that can be reached online.
Probably the best choice. But people could just take down their firewalls for testing, or, better yet Windows does allow you to chose which programs can pass the firewall. I don't know for sure but OSX and some Linux Distros should allow it as well.
OS Firewalls aren't the problem, router firewalls/port forwarding are. Those are configurable too, but it's harder and if you're unlucky your ISP still doesn't let you have incoming traffic.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests