I am working on a TCG game where I want to be able to play against an opponent over the internet. What is the easiest way to implement this without needing an external server. One player would select to be host and the other client and the client would enter the host’s IP address. Is there a sample project I could view or can someone point me in the right direction?
Maybe start with a chat client/server?
It seems to me the easiest way to pass more random data between two or more ip’s
Why two apps ? You can have sessions communicate as shown here :
https://forum.xojo.com/2821-session-to-session-communications
That way you can use the same UI, and no need for users to enter an IP. All they would have to do is use the nickname of the other player.
[quote=140739:@Michel Bujardet]Why two apps ? You can have sessions communicate as shown here :
https://forum.xojo.com/2821-session-to-session-communications
That way you can use the same UI, and no need for users to enter an IP. All they would have to do is use the nickname of the other player.[/quote]
This is precisely what I want to avoid as I don’t want to pay for hosting web apps. The game itself is a standard Win/Mac app.
You mean you want to distribute apps that will execute on the user machine ?
Admitting firewalls and nats don’t get in the way, you could probably have the two apps communicate through TCPSocket.
I just don’t know where to get started.
look next to the Xojo IDE executable file in
Example Projects/Communication
At first glance, there are projects that may just suit your need :
ServerSocketClientTest
ServerSocketServer
SynchronousTCPSocketExample
I looked at them but I am still confused. I tried the Client/Server examples but if I use my home external ip address it doesn’t work as I get error 22. I guess NAT is the issue?
If I try it on another computer in my network and use the external IP address I get error 103.
You have to understand I am new to trying to connect over the internet.
EDIT: I see that putting my external IP address into a browser, I loads my modem’s login page.
[quote=140747:@Charles Fasano]I looked at them but I am still confused. I tried the Client/Server examples but if I use my home external ip address it doesn’t work as I get error 22. I guess NAT is the issue?
If I try it on another computer in my network and use the external IP address I get error 103.
You have to understand I am new to trying to connect over the internet.
EDIT: I see that putting my external IP address into a browser, I loads my modem’s login page.[/quote]
Sorry to read your experiments did not work. Over the local network it usually works quite well. The 103 error seems odd.
However, I am not surprised it did not work on your general IP. As a matter of fact, NATs are usually set not to allow access from the general internet to local machines, as a protection against attacks. And it is the same for firewalls. Actually, even when running a Xojo Web application on a computer, it is usually not visible from the general Internet either.
Even peer to peer use some kind of magic to perform through these obstacles, and it is far more complex than a simple TCPSocket.
The simplest way, really, is to use a host, at least to support communication between computers through HTTPSocket. Since you do not want to rent a host Xojo WE is out of the question, but you may be able to devise something in PHP that runs on one of the zillions free hosting. See https://duckduckgo.com/?q=free+hosting+php
Problem is, such an endeavour is extremely far from being simple…
I know nothing about PHP. How is it done with game where the company shut down the servers and players then use their own private servers to keep playing? I thought it was as simple as player 1 hosts the lobby and the other player joins the lobby. I guess there’s more to it than I thought.
I used to play this TCG game years ago where all you did was select either host or client. If you selected client you entered the other player’s external IP address and each player’s copy of the game connected no matter where they were in the world. I don’t need anything fancy right now. It’s one-on-one so one player hosts the game and the other player connects. There was only one executable file involved. Were they using a web server to help players connect to one another?
[quote=140762:@Charles Fasano]I know nothing about PHP. How is it done with game where the company shut down the servers and players then use their own private servers to keep playing? I thought it was as simple as player 1 hosts the lobby and the other player joins the lobby. I guess there’s more to it than I thought.
I used to play this TCG game years ago where all you did was select either host or client. If you selected client you entered the other player’s external IP address and each player’s copy of the game connected no matter where they were in the world. I don’t need anything fancy right now. It’s one-on-one so one player hosts the game and the other player connects. There was only one executable file involved. Were they using a web server to help players connect to one another?[/quote]
Unfortunately, nothing is ever simple when communication is concerned. It actually takes a lot of hard work to make things simple for the users.
I am convinced what you describe would be possible through a web app that bridges users computers, pretty much like a phone exchange works. Doing that directly between computers is theoritically possible, but since they are heavily guarded against intrusions, it will require quite a bit of setup to make it work through all the firewalls, nats, and antivirus software.
Are there any pre-built web apps that I can use on a free host that would suit my needs?
EDIT: I looked up the game I use to play and the connection method was called IP to IP connection.