Multiplayer dont work without local :/

Started by Lucasnonime, October 26, 2016, 16:36:41

Previous topic - Next topic

Lucasnonime

First off sorry for my English :>

I am developping a java 2D game with lwjgl in multiplayer. I followed the vanZeben's tutorials about multiplayer (https://www.youtube.com/watch?v=l1p21JWa_8s). All is fine in localhost connection. (i'm using the port 1331).
Now i try to connect with friends but nothing :/. I changed the localhost here
socketClient = new GameClient(this, "localhost");
by my ipV6, i tried ipV4 too, i tried to connect with Hamachi but nothing at all..
I forwarded my ip (i think oO) following to this: https://www.youtube.com/watch?v=dXxdpfBxCRI
Nothing, nothing and nothing.
If someone can explain me how to do it.. thanks you  ;D

seventh-chord

It seems like you are hardcoding the IP address. You really should find some way to have your friend enter the address when he wants to connect, either using an ingame menu or a command line parameter. That will make it a lot easier to try out different addresses. Also, have you tried connecting from another location within the same network, without the need for port forwarding?

Lucasnonime

QuoteAlso, have you tried connecting from another location within the same network
How am i suposed to do that ? oO With Hamachi? Wait maybe you dont know what is Hamachi, i'm french and maybe its a french software ^^

seventh-chord

I have heard about hamachi, but what I was thinking about is something different. When you have two computers connected to the same local network (Same router) you do not need any port forwarding or fancy tools. You simply use the local ipv4 address of the computer you try to connect to. Your OS will have some tool for finding this address (ipconfig on windows, ifconfig on linux). For example, all computers connected to the same router as me can reach my computer at 10.0.0.89. This will not work with your friends on a different local network, but it is a good way of testing if the game actually works.

Lucasnonime

So Hamachi permite that u_u. I arleady tested, nothing different without or with it.
Edit: just understood your message xD. " thinking about is something different " What is this ? ^^. I
"if the game actually works." It works, in localhost i can connect multiples accounts


bobjob

what Operating system are you running it on?

Once you answer that, I can explain how to find your local IP address. Once, you find your local IP address, you can put that address in as long as your friend is on the same local network.

socketClient = new GameClient(this, <<PUT YOUR LOCAL IP ADDRESS HERE>>); //DO NOT PUT LOCAL HOST ON YOUR FRIENDS COMPUTER

It gets a bit more tricky trying to connect over the internet.

Lucasnonime

I am on windows and i know i must not put localhost to connect with my friends --"

Lucasnonime

Quote from: Lucasnonime on October 29, 2016, 10:05:41
I am on windows and i know i must not put localhost to connect with my friends --"
Quotein as long as your friend is on the same local network.
If that mean i can connect with hamachi that's ok for me.

bobjob

In this youtube video at 12 seconds he points to the IP address on his computer. Open up that application to find out yours.

in his version it is "25.1.23.38" you need to find out yours and use that number instead of "localhost".

Connect to your own computer using your hamachi IP. If it works on your own machine and not your friends, the problem will be either be a routing issue, or a issue related to buffering in your code.

Lucasnonime

I already dix that, i know my IP adress. But that dont work

Kai

With your ServerSocket, did you bind to localhost?
If yes, then you have to bind to the wildcard address (IPv4 "0.0.0.0", IPv6 "[::]") or the address of your network adapter connected to the router/internet.
Otherwise, no connection will reach your process when it only listens on connections established from processes within the same host.

Lucasnonime

UUh more slower pls xD.
How i am suposed to bind ?