Multiplayer Networking
BlitzMax Forums/BlitzMax Beginners Area/Multiplayer Networking
| ||
Hi all! It's been quite a while since I've posted here on the forums (the search function does it's job well. haha.) I'm looking to learn more about blitzmax's networking functions, and am running into trouble. Any pointers would be greatly appreciated. I've already found several posts on various Bnet and Gnet tutorials. Short GNet tutorial Online and Network Tutorials BNet UDP Multiplayer Tutorial GNET tutorial that works? All of which have not been much help. It seems there are no recent Gnet tutorials and reading through Blitzmax's documentation has not helped me either. Nor have I been able to find Raknet which appeared to at one point be a module from Brucey, and being worked on by Zeke as well. However, all those posts are 6 to 10 years old. (boy does the time fly.) What is the current consensus of what library to use? Gnet? Bnet? Raknet? others? I would like to begin developing a multiplayer function to a game I'm working on in my spare time. Thanks for the help. B |
| ||
Gnet builds on "eNet" (pub.enet). So you could facilitate the functionality of that library already. Seems it cannot handle broadcasts (one package to your complete local network) but dunno if this is a requirement for you. @Gnet there is a sample in the samples folder (samples/mak/gnetdemo.bmx) bye Ron |
| ||
Thanks! This might put me on the right track. Looking through the gnetdemo sample now. Wouldn't have thought to look in the 'mak' folder for it. With my previous experiments in Blitzmax and Unity the biggest issue I have so far is the program works fine with all computers connected to my router, but doesn't see computers connected over the web. For example at my brother's apartment, he can't connect. Thought it might be a port forwarding issue, so we've forwarded some ports I'd like to use (UDP). Still can't get my head around the exact way this whole thing works. I'll have to see if the demo can connect from his place. EDIT: I got the demo working between my laptop and desktop using my ipv4 address to connect to. In the past I've uses my outside address (I google 'whatsmyip') to have others connect to me. This never seems to work. Is there something I'm missing? Thanks again. |
| ||
portforwarding allows to reach a certain port on your computer via "wan ip" (internet ip) and a port. so forwarding port 1234 to 192.168.0.2,port 5678 means any packet send to "wanip:1234" is received by your router and redirected to 192.168.0.2:5678 Now you need an app listening to the socket at port 5678. For UDP you have the problem, that you often just do not define which port is used at all. you send an packet and afterwards you know which port was assigned this time. If you defined the sender port, than it should work already. If you cannot define that port, you might think of using an additional TCP-channel (which allows defining the outgoing-port). If you think you did everything correct, then setup WireShark (or another port sniffer) and check whether the data flow is correct or not (if internet-traffic is coming in etc). Setup the filter to your ports to skip the other packages flowing in and out of your NIC. bye Ron |
| ||
I have been keeping the service and internal ports identical, thought that would be easier. Is this bad practice? Here's my logic thus far. I forwarded Service port 3849 to my ipv4 192.168.0.100 and Internal port 3849. I give my external IP to my brother at his apt. (PORT was set as a const) Host was created using: Local host:TGNetHost=CreateGNetHost() In the game code he executes the connect cmd in game which uses this code: If Not GNetConnect( host, externalIP, PORT ) Notify "Connect failed" He typed everything correctly and my game was currently: GNetListen(host, PORT) So im assuming my external ip will be translated by my router to my ipv4, and since both ports have been forwarded and the game is currently running it should work. Is this how it works? EDIT: PS: Does it matter whether his port 3849 is forwarded on his router as well? After using CurrPorts it sees my game on the correct port, but does not say connection is established, does not see a Remote Port, or Remote Address, or Local Address. Using YouGetSignal.com says that the port is not currently open. I assume that is true because no data is currently being pushed or pulled through that port. |
| ||
Does it matter whether his port 3849 is forwarded on his router as well? Usually, only the server needs to open its ports. But since eNet uses UDP both might need to, it depends.I suggest creating your Client and Server and debugging them locally before trying to connect over the internet. IE: Make sure the client and server can actually send messages to each other. |
| ||
@grable Currently everything works fine locally. However, now I'm thinking that possibly his port wasn't forwarded. He said he removed the forward after initial testing. Maybe he forgot to put it back on. |
| ||
Check what kind of PortForwarding you configured on your router (TCP, UDP, BOTH). More important is: what is your ISP. Do you have "cable" ? Often they give you "DS-Lite", which means you do no longer have your own IPv4 adress - you share it with 100 other users. So reaching your router from outside wont work that well then (how to know which of these 100 users was meant when addressing your WAN-IP). So if this is the case, you wont be able to do it "the easy way". Dunno how to do IPv6 with BlitzMax though. If you want, download XAMPP (or start another local server). Forward port 80 to your local ip and check if your brothers computer is able to connect to your "website" then (http://yourWANip). @not currently open It does not matter whether you send data in that moment, there is a listener for that port and one someone knocks at this port, it might react. bye Ron |
| ||
No need to download a server. This sample will do: |
| ||
@Derron I have Time Warner Cable. After chatting with a representative online they said that they do use Dual Stack Lite. So this might explain all my problems! boooo... Checking on that XAMPP thing now. @grable Thanks for the code. It works for me when I use my ipv4 and my external ip. If an outsider used "http://my external IP" would they get the same 'SUCCESS' result? Does this mean that I just have to learn socket programming in Bmax and all my troubles will go away? (...ya like it's that easy) |
| ||
If an outsider used "http://my external IP" would they get the same 'SUCCESS' result? Most likely yes. Your router/provider might do a loopback, so the true test is from someone outside their network.But i doubt they ignore outside connections like that. So your good to go :) |
| ||
Exactly what is the difference between using BRL.SocketStream and Gnet? Does Gnet just use sockets at the base level? Will using socket streams be limited to TCP only? I've read online that for games where time is a factor you want to use UDP. My game only has a few variables that need updating as fast as possible: x, y, health, max health, animation frame, current action, missile x,y, everything else doesn't have to be sent over the web. My idea is to have online interactions appear as smooth as possible as possible. Like the other player is just an NPC already in your world to help or hinder your progress. (Exactly like the Dark Souls series.) My plan is to create a server running on my desktop. Upon starting the game it connects to the server and it's IP gets added to a list. The server then will take incoming requests from a player wanting to help/hinder another player when they trigger an event in game. The server will then select another player that is still online and in a compatible location, and hand over their IP. Then the two players will be connected to each other rather than the server. Does this make sense? Is this possible using BRL.SocketStream? |
| ||
An online game is perfectly doable with TCP. The reason people favor UDP is for low latency and broadcast options among other things. But for small time stuff it doesnt really matter that much. GNet uses ENet which uses UDP. So there are some layers in between there too, possibly adding to the latency. But again, for small stuff it doesnt matter. For the intermediary server doing negotiations between clients, using TCP with a text protocol is good enough too. For the direct connect stuff, all clients requesting another player would then have also have to have the relevant ports open. As they would then have to listen for outside connections. Which might not always be possible. As you know ;) Doing it without direct connect takes more work though, and requires a faster internet connection and possibly machine to handle the data for all clients (though it doesnt look like there will be much of that in your case) In any case for your purposes i suspect GNet is easier to work with as it syncs data between connected peers automatically whenever something changes. And it would probably use less resources as well. |
| ||
Great information. Thanks! I guess I'll just do some more trouble shooting and see where that leads me. |
| ||
- your provider might handle ":80" (just check that by test-using port 80 in your gnet-test) - try out "BNetEx" (an udp-blitzmax-module) if you think there is a problem with enet/gnet http://community.bugbeargames.com/index.php?topic=6063.30 http://steamcommunity.com/app/107410/discussions/0/38596747866548836/?l=swedish ... When trying that "port 80" thing (gnetdemo with 80 as port), check your openport-website if it is open then... A question on the port 80 thing: did you port forward port 80 to your local computer or did it "just work"? (normally you should port forward, except your router made some assumptions, which I doubt) If you made sure, that the problem is something with the ISP, then "hole punching" might help: - somehow you need to know the IP and sender port of the other side: - - eg. by sending a request to a public available server: - - - client->server: "I want to host" - - - server receives packet "ip:port, I want to host" and stores it - - - client2->server: "I want to play" - - - server receives packet "ip:port, I want to play" and stores it - - - server->client packet "client2ip:port, wants to join your game" - - - server->client2 packet "clientip:port, awaits your join" - - - ... - now both, client and client2 know the used IP and port of each other but are not able to send packets to each other (without port forwarding) - hole punching uses the trick, that outgoing packages from a:portX->b allow b to answer to a the same way (b->a:portX) - so the first packet from client->client2 is rejected, but once client2 sent a packet to client (at least tried so... as this gets rejected too) they both are able to send packets. Both opened their doors for the other client. BTW: senderPort might differ in the case of multiple clients on the same computer. This is why you cannot rely on fixed ports but need to be aware of variations. This means, you use the port you get when receiving packets, not the port the sender says it uses. bye Ron |
| ||
In reference to the "port 80" thing, are you talking about the code grable posted? If so: I ran it a couple of times, it gave the same result each time, first without the port forwarded, then with, then without again. It worked when I typed in http://myIPv4 and http://myexternalIP. I'm going to test the gnetdemo with my brother on service port 80 with it forwarded to my ipv4 to internal port 80, when I have the chance. In regards to the hole punching, am I understanding this correctly? Once two clients have sent a packet to each other, and those packets have been rejected, they can send more packets via the same route and they won't be rejected? Say if A sends a packet to B saying "I'm here" and B sends a packet to A saying "I'm here". Both get rejected. But since neither has received a response they just send out the "I'm here" packet again and it will go through as a result that both have sent packets through that port already? Is this a result of both A and B sending a packet from their 'port X' and because of that the port leaves itself open? I'm not sure if I'm understanding 100%. I'll continue testing Gnet, and if I think there's still a problem I'll check out that BnetEx module. EDIT: After reading the first link you posted, I'm wondering if my port forwarding through my router isn't actually forwarding the ports because my ISP uses DS - Lite. Do you think this is possible? |
| ||
B: Once two clients have sent a packet to each other, and those packets have been rejected, they can send more packets via the same route and they won't be rejected? Yes, this is called "hole punching". The router accepts incoming packets as soon as one from "local" has sent a packet to the "incoming sender-ip:sender-port" before. More information: https://en.wikipedia.org/wiki/UDP_hole_punching https://en.wikipedia.org/wiki/Hole_punching_(networking) (there is also a "flow" example there... which is maybe more understandable than mine). @Port Forwarding You said, you reached your server at port 80 without manual setup port forwarding - are you sure your brother reached your computer via the external IP? IF so, I assume something is wrong then ;-) How should his computer know which of your computers behind the modem/router is listening to :80 (the default port when just using "http://your.public.wan.ip"). What would happen if you had two computers behind your router, both running that sample posted above? This is what port forwarding is for. It would only work, if your router is in "Bridge mode" (just exposing your whole local network to the public, no filtering, no securing) or with the old "PPPoe"-approach (your computer is the modem sharing its connection to the LAN). @DS-Lite As far as I know you cannot port-forward with DS-Lite (as I explained already) as many people share the same IP(v4). How should your provider know who is meant when your brother calls "http://wan.ip.of.many" ? There are "IPv6 to IPv4"-helpers online, which translate "my.anyDynamicIPService.com" to your individual IPv6. I did not use them for now so I cannot help you on this. IPv6 is individual for each computer, so there is no need for port-forwarding (each computer is addressable individually). Maybe for "IPv6" we should ask for help in the community (with the right keywords in the thread... "IPv6 GNet/Multiplayer - How To?"). bye Ron |
| ||
To clarify @Port Forwarding the http:// my.public.wan.ip worked when I typed it in my own browser regardless of Forwarding Port 80 or not. I just got my brother to try it just now, and it worked with the Port Forwarded. I didn't try it without the Port Forwarded, not enough time. More importantly tho! I got the gnetdemo working! With my Port 80 forwarded on my side and Port 80 not forwarded on his side. He was able to connect to my public wan ip. However, I was not able to connect to his. I assume because his port wasn't forwarded. And I wasn't able to test any other Ports. Good news though! This means others can connect to my server and get data. Then I can try hole punching to connect clients together. More testing is needed. |
| ||
Next try if your custom port works too (should do!). Your brother does not need to forward port 80 (or your individual then) too. This should only be needed for the server, to be publically available. Once the client (your brother) connects to the server, he already initiated a connection to you, and any response of you to your brother (sent to your brothers IP:port he used when sending his initial package) will then automatically be ok (you "hole punched" then already). @you connecting your own public.wan.ip This wont work, as your OS already knows your public-ip and therefor "loops" your request (you do not generate outgoing/ingoing traffic...). @got the gnetdemo working So what did you have to do to make it work? bye Ron |
| ||
Just a heads up, exposing known ports like HTTP(80) is not a good idea unless you have a battle tested server. As there is rampant port scanning and vulnerability searching all over the internet at all times. I recently made a HTTP server for serving files to friends, and having one open on port 80 publicly for 3 mins and i already got 4 random connections with bogus data. Use ports >1024 as they are not as often port scanned. |
| ||
having a server running for test scenarios means often: you installed an up-to-date-server. Also you wont run it 24hrs/day. My NAS runs a simple webserver + php 24hrs/day and got not hacked or so. Of course people scan your services, they aren't all bad boys just because they do this. Exposing something _non-web_ at port 80 is might be even better. Also there are some games around using port 80 because often restrictive firewalls (read: companies) allow HTTP/HTTPS/POP/SMTP/IMAP but nothing else. bye Ron |
| ||
Im not saying never do it, just be sure that the server your using knows its shit. Like IIS, Apache, Nginx etc. And that it is properly secured. I of course made my own HTTP server, and there are a lot of small things that needs to be taken into account. Like error checking every little thing, making sure it can handle bogus data gracefully etc. That is doubly so when using another protocol then the expected of the port, as then you WILL get "bogus" data. Except in the case of TCP vs UDP of course. |
| ||
How reliable is this method? "Get External IP" from code archives It missed the last digit of my IP, so I changed this: ipEnd= Instr(MyParsedIP$,"</body>",1)'-1 Just commented out that -1 and it works fine for my particular IP. But doesn't that mean this method won't work perfectly for everyone, as IP's are not a standard set of numbers long. However, this site takes forever to load in my bmax game. Users will probably task kill it thinking it's a bug. I found this site ipinfo.io that just spits out the number with very minimal html and parsed it to get the right address for me. Works instantly in my game. I just changed this: ResultBank:TBank=LoadBank("http::checkip.dyndns.org") and ipstart=Instr(MyParsedIP$,":",1)+2 ipEnd= Instr(MyParsedIP$,"</body>",1)-1 To this: ResultBank:TBank=LoadBank("http::ipinfo.io/ip") and ipstart=Instr(MyParsedIP$,"y>",1)+1 ipEnd= Instr(MyParsedIP$,"</body>",1)-1 I know this method will only work as long as the site remain up. Any ideas on a better way to get your current External IP inside of Bmax without connecting to a server and have it give it to you? (I'm thinking of trying to somehow parse a google search for 'what's my ip', because I'm sure google will always be online.) |
| ||
All those IP showing sites may ban you for excessive use though. And as you have noticed a lot of them can be slow too. You can use raw sockets and use ICMP packets to ping an address, get your ip that way. But its a rather involved process. Or you can cheat and call ping instead ;) |
| ||
Thanks for the heads up on the banning. I don't wanna anger anyone. @cheat ping call I'm only getting 'unknown' back. ip:string is not getting assigned somehow. |
| ||
Hmm.. try running it in a terminal and see what it spits out:ping -r 1 -n 1 www.google.comThe expected output: Pinging www.google.com [84.208.42.39] with 32 bytes of data: Reply from 84.208.42.39: bytes=32 time=9ms TTL=59 Route: 111.222.333.444 Ping statistics for 84.208.42.39: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 9ms, Maximum = 9ms, Average = 9msThe IP should come after the "Route:" part. Might be some version differences im not aware of (using Windows 10 here) |
| ||
oops dbl post |
| ||
First off, I really appreciate all your help my friend. I'm using win 10 as well. I'm getting everything except the Route: 111.222.333.444 After googling ping cmd arguments I can't seem to find an -r argument. https://technet.microsoft.com/en-us/library/cc737478%28v=ws.10%29.aspx This doesn't show it exists. Here's what I'm getting C:\Users\myname>ping -r 1 -n 1 www.google.com Pinging www.google.com [74.125.28.106] with 32 bytes of data: Request timed out. Ping statistics for 74.125.28.106: Packets: Sent = 1, Received = 0, Lost = 1 (100% loss), and this if I leave out the args C:\Users\myname>ping www.google.com Pinging www.google.com [74.125.25.103] with 32 bytes of data: Reply from 74.125.25.103: bytes=32 time=149ms TTL=40 Reply from 74.125.25.103: bytes=32 time=67ms TTL=40 Request timed out. Reply from 74.125.25.103: bytes=32 time=56ms TTL=40 Ping statistics for 74.125.25.103: Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), Approximate round trip times in milli-seconds: Minimum = 56ms, Maximum = 149ms, Average = 90ms Same results when I use Cygwin or Windows Powershell. |
| ||
If your using Windows 10 its there.. typing "ping" alone will show that. Its supposed to trace the route the packets take as well as pinging. But tracing takes time, so it seems to timeout easily for slow connections. And now that i think about it that DS-Lite thingy might mess things up further, i dont know. You could try increasing the timeout with "-w <milliseconds>", since your maximum is 149 try 200 or 250. Or try increasing the number of pings with "-n <number>" and hope one of them goes through. Once you have a recipe that works, you can plot them back into the sample and see if it manages to parse it correctly (it should, so long as "Route:" is present) Though this all makes it a tad unreliable... :/ |
| ||
Sorry, you're right. Typing ping shows -r, but microsoft's website doesn't. meh.. I thought you might have add some extras installed or a different terminal or something. now when I run it. C:\Users\myname>ping www.google.com Pinging www.google.com [173.194.203.105] with 32 bytes of data: Reply from 173.194.203.105: bytes=32 time=51ms TTL=38 Reply from 173.194.203.105: bytes=32 time=52ms TTL=38 Reply from 173.194.203.105: bytes=32 time=43ms TTL=38 Reply from 173.194.203.105: bytes=32 time=47ms TTL=38 Ping statistics for 173.194.203.105: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 43ms, Maximum = 52ms, Average = 48ms Slightly better ms, but still no Route: and any arg of -r # always timesout. Usually I get quite decently fast internet.... Throttling?... dum dum DUM! Maybe just a busy time of night here. in cmd when I type 'ping' it says -r is (IPv4) only. I feel like that's my problem. and ya, makes it quite unreliable. :C I've decided that I'll just execute the parsing of that website once upon first game launch and then save the users IP to a file along with the rest of the data. Then as long as the data is there I won't need to bother the site unless there's a problem connecting in which I'll do it again. I made my first little Gnet game thing tho, not very impressive yet, but it's on the way. Connected perfectly with my brother on ports 80 and 3849. I have both forwarded, he didn't. Now to just write the server... Little screenshot: |
| ||
Seems like the most reasonable way yeah. Like the look of your game too, reminds me of those old Sierra games :) |
| ||
Thanks! Oh, those were my favorite. I love this art style and ASCII as well. |
| ||
@port 80 Once your custom port works, do not use it - if one works, the others should do too. Also, your brother does not need to forward that port too - except he "hosts". You do not need to know _from_ which port the other players join your game, they use whatever port is available for them. Imagine your game host being a post box. People handing in letters (that thing out of paper :-)) write their sender's address on it. These people will have to know where to find your post box ("abc street 123" - "abc street"=ip, "123"=port). From the moment of handing it in you know the sender's address and are able to hand back the letter if they forgot to pay for the stamp :-). This example also shows, that address data could be faked... @what is my ip For this I have my "lobby" on my own server/website. Just a simple PHP-Script/"API" responding to certain commands. So a "mygame/GetIP" returns the plain IPv4 of the requesting client (the game of the user) ,"mygame/ListGames" returns serialized data of currently announced games (gamename, playeramount, playermax, ..., hostIP, hostPort). "mygame/AnnounceGame?gamename=..." expects the gamename, playeramount... and adds them to the list of games, or updates the corresponding entry (gameGUID). So this little script acts as "lobby" - your hosting game client informs the "lobby", everybody wanting to play your game knows that "lobby" (url and how to reach it), they do not need to know you. Once they want to play, the ask the "lobby" for the list of games. Now they know every game currently waiting for players (you could introduce filters for specific users or game titles... so the server only responds with a smaller list). With that information you could eg. show a list of available games and upon a click on once of that games, the "/join ip:port" could automatically be executed. bye Ron |
| ||
@Derron Thanks for all the help. Everything seems to run fine except one little hiccup. My brother and I were both at our parents house over the weekend, so we did some testing. I'm using port 3849 exclusively now and it works perfectly well when I host and my bro connects to me using my IPv4. The port has not been forwarded on my Dad's router. The problem is when he hosts and I attempt to connect to him on his IPv4. It doesn't work. I tried ports 3849, 80, 2500, and some others. I couldn't get it to work when he hosted and I attempted to connect to him. We were both running the exact same .exe file, and we both made sure our windows firewall wasn't blocking it. I can't figure it out. This might all work fine after I write a server, but I don't have the time to tackle that at the moment. Any Ideas? Thanks again! |
| ||
Would you try accessing that small "webserver" (post #9) on your brothers computer? If this is not possible too, then something might block. Like I said, it is good to have "wireshark" installed for such purposes: run it and it records all incoming and outgoing traffic. Now filter that to your specific port and voila, you see if your packets are going out, and if some packets come in in return. Also make sure whether both of you are able to connect to their "server" locally (two instances of your app on one computer) - if this fails, then your code might contain bugs (eg. it fails on creating the socket or so). bye Ron |
| ||
Thanks to all contributors for some illuminating data. One question though can one (router)port that has been forwarded to a particular port on one IP, be shared with another port on another IP on the same LAN. Have fun Cps |
| ||
I did not really get what you want to achieve? router port X -> computer 1 port X -> computer 2 port X Think this kind of "relay" isn't possible that easily. You could sniff all incoming data on computer 1 and forward this to computer 2 on your own (to whatever port). Another keyword is "unicast" - so similar to a video on a normal cable tv it is "broadcasted to all". Not all routers allow such unicasting. bye Ron |
| ||
Many thanks for the feedback/keyword I'll have to investigate. The object was to avoid setting up multiple ports on a router to forward to each computer (IP) that needed port forwarding on a local network, one port being easier from an admin point of view. hope this makes it clearer. Have fun Cps |
| ||
NO...just do not do that (=> bad habbit). Your router does know who sent a packet to an external receiver - this allows hole punching (allows to receive responses from the receiver to the sender). Your router does _not_ know who is addressed when it receives an initial packet to "my-internet-ip:Port". This is where port forwarding comes handy: it allows to guide incoming packets to the right receiver. If you now would relay every packet to portX to all-local-computers:portY this might work. You could check, what happens if you use port forwarding to 'mylocalip.255:portX" (so eg. "192.168.0.255"). 255 is most often the broadcast address of your LAN. (check it by "ping -b 192.168.0.255" - multiple computers in your LAN might respond - in my case none of my systems responded, which seems "normal" for my setups). Maybe broadcasting via 255.255.255.255 works too. If that would work, it might still lead to trouble: what happens if two computers in your LAN want to communicate with the same remote computer on the same port? How would your router know who the remote one wants to send a packet to? What is often used is this approach: wanIP:port1 -> 192.168.0.1:port1 wanIP:port2 -> 192.168.0.2:port1 so for the application on the client the port "port1" was used, but for the remote computer both clients have individual addresses: wanIP:port1 and wanIP:port2 In your app you need to attach the "public port" to some information packets so the receiver knows what address port to use. The "envelope" of the packet contains "wanIP:port1" but to answer, it should use eg. "wanIP:port2" (for the second computer). Also do not forget: - port forwarding only works for IPv4 - port forwarding does not work for IPv6 or ds-lite (multiple internet users share one single IPv4 address) With IPv6 you do not need port forwarding as each computer has an individual (and publically reachable - make sure you are using a router then!) address. bye Ron |
| ||
Thanks again, looks like IPv6 is the way to go. You have given me plenty to think about, I'll to put it to good use making my multiplayer things work over the internet instead of just over a LAN. Have fun Cps |
| ||
IPv6 wont work with IPv4-only connections (eg. mine - I downgraded from IPv6 with ds-lite to IPv4 as I offer some services for the computers of my parents and my smartphones). Also I do not know how to tackle IPv6 with vanilla BlitzMax. bye Ron |
| ||
Thanks for the warning I'll stick to IPv4. I'm going to absorb and apply what I've picked up from thread above. That way I'll avoid asking a question that leads back over old ground. P.S. I'm using the GNet structure for network commands and the Gnet lobby for announcing that my server is ready for a client and providing the client with the servers name (encrypted). All working well on a LAN (with an internet connection via a router). I'm just having to get to grips with the port forwarding methods described above to enable play over the internet. Have fun Cps |
| ||
I use a gnet-a-like networking basement: - configurable local port (or range - in the case a port is already used, eg. second local client, other app ...) - online lobby for making games known to remote computers - local broadcast to make game available on LAN If you host a game, the game with your WAN-ip and used port is send to the lobby. If you want to join a online game, you ask the lobby for games, they send then the wanIP:port of the game host. Connection is then established using the common functionality. the "joining user" does not need to do port forwarding then (hole punching) but I used to do port forward to ease the pain. bye Ron |
| ||
I had a quick look at your web site (nice). I assume that your lobby is in web space (not a local server) and runs under either php or java and that it contains all the information needed for connection between clients and servers in a data base. This looks like something I will have to learn, as the GNET lobby only provides; session name, server name and seemingly the router IP as seen by the internet. Thus these exchanges about port forwarding have been really helpful. As an aside; I do like the direct x7 direct play concept of a Game Unique Identifier (GUID) in a peer to peer environment (Jack Hoxley's articles) but that's not going to work for Mac's. Have fun Cps |
| ||
Sorry but I forgot to ask about communication failure timeouts over the internet. At the moment I'm allowing about 60 seconds before my programs report and recover from a communications error. This is plenty of time for a LAN, but what sort of delays have you allowed for in your over the internet games ? Have fun Cps |
| ||
the whole networking aspect is prone to be redone some time in the future. I think delay handling depends on the game you do. It depends on whether the game is run on a server and the clients only display things and send their inputs - or whether each client computes the whole game on its own and just receives the input of the others. If you use the second approach: - read about "lock-step" (kind of simulation turns and waiting for inputs for the next turn), this might involve, that all your inputs could be stored as "commands" - read about floating point determinism and/or avoid floats at all bye Ron |
| ||
I'm doing 2d, 2 player alternate move based strategy games (The Viking Game, Tri-Tactics etc) so speed of connection isn't important. Only the individual moves are communicated with each cpu processing the move data, so the second approach you described seems appropriate. Thanks again for the pointers, I've got some serious reading to do. Have fun Cps |