need help with bennuplaynet.dll for simple online server/client

Started by cmunoz, April 08, 2015, 10:42:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cmunoz

I've been trying to learn about programming of server/client networking for games. I have been able, thanks largely to the great examples provided, to get a simple server/client concept working within my own pc. Now I'd like to get it communicating over internet and lan. I've tried everything I can think of like replacing "localhost" with my public ip, private ip, turning off firewall, trying different ports, etc. but no luck. I just can't seem to figure out the next step in getting this thing to play online. Any pointers would be greatly appreciated.


Meanwhile, I'll keep working on it and will update as I figure things out.

cmunoz

I replaced the "localhost" with the Ip4 Address of one computer on LAN, and ran the server on this computer. I ran one client on this computer, and the other client on another computer on LAN. It worked briefly, but the server seems to drop the connections with the clients after a few seconds.

JaViS

Working on Anarkade. A couch multiplayer 2D shooter.

cmunoz


I'm trying this out again, and so far it's keeping the connection much longer. I've been running it for about 15 minutes straight and I haven't seen it crash yet.
I just wish I knew why it would not persist before.I've only tested this within LAN, but I'll post any updates after I attempt to test outside of local IP.

I'm attaching the latest versions of the files for anyone who's interested.
To get thist to work, you must also create a file called server_ip.txt
Open this file and in the first line, simply write the IPv4 address of the computer with which you will be running the server.
Save this file in the same directory as your client.dcb file.

Clients can also run on the same computer as the server if you don't have two computers handy on the same LAN.

panreyes

Hi Cmunoz,


I'm developing another method to make BennuGD's games playable in LAN, but with fsock instead of bennuplaynet.


One question, what does your code do? As long as I can see, it sends some data from the client to the server, but, does it send something back?


Thanks!

cmunoz

That's great to hear, and thanks for asking!
Basically I have a type called _PlayerData which includes a few variables such as the location of the movable x, and also whether a button is being pushed. The type is shared from each of the clients to the server. The server reads which of them if any is pushing their button. The server decides, based on who is pushing their button, how x should be moved. It then shares back the _PlayerData struct, which the clients read only to know where the x cursor should be located. That way the "game" itself takes place only in the server, sending updated location to the clients, who do not connect to each other or run the game engine themselves. I hope this is a good explanation, let me know if anything is unclear.
Also, I'm not sure if this is the best way to implement this, I have no real training in coding, so there may be a simpler or stronger/more effective way of achieving this. My goal is to get online play capability for a sort of rpg fighter (think pokemon in real time) that I've been creating, so I started with this very simple server example.


panreyes

Okay, I understand.


The problem I think you're facing is the same as mine: high latency.


In fact, in the way we program our games, we will always have problems with latency, as if we develop a game at 60fps we could only support it at a max of 16ms of latency.
If we did it 30fps, our max latency would be 33ms.


I don't know if I'm explaining myself right, but in the end our most important problem is the latency, and I don't know how to solve it easily...


Here's an example of what I'm doing:
http://www.explosivedinosaurs.com/web/blog/en/7


Regards!

cmunoz

PiXeL,
Yes, the description about eXplosive Dinosaurs sounds exactly like what I'm  doing here. My actual game animation runs at 24fps, so I figured doubling the frame rate to 48fps for the netplay would give me less latency, am I right?
What's interesting, is that the server/client connections seem to be working fine now, and not losing the connection at all. I had it running for over four hours today and it kept working fine, never lost connection. And I can't explain that because when I had tried it previously it would run for maybe ten seconds before it lost the connection. I'd sure have more peace of mind if I knew why it's suddenly working correctly.


FreeYourMind,
Thanks for the example, I'll start taking a look at that asap!

panreyes

Also, cmunoz, you don't have to worry about losing connection once in 4 hours.
You have to think a method to resync easily if a "message" is lost, which is going to happen a lot.

cmunoz

Yes, that's true. That's one reason I wanted to go with client/server and not peer to peer, so the server can keep things in sync better.
I did an earlier version with a different library, was it libnetwork? I can't remember. But I had tons of latency problems and after doing some research and learning about TCP and UDP I finally understood that I was losing packets which was slowing things down.
Haha,  before this project "the internet" was, to me, just some kind of magical thing that I had no clue about!
I have much to learn, and I'm grateful for your help.

cmunoz


Thanks again for the support on this thread.
So far I've been conducting these tests on several different computers within my own LAN setup, using the private IP of the computer running the server.
If I wanted, for example, to play online against a friend on the other side of town (i.e. outside of my LAN) I would need to give him an IP address to connect to. Unfortunately my public IP address didn't work in connecting him to the server. Now from what I'm reading, it seems that's one of the functions of a router, to provide security for the LAN?
I've come across some articles about port forwarding to create a static IP for a specific computer on which I'd run the server. I'll definitely want to do a lot of reading up on the subject before I start messing around with router settings, but I thought I'd post an update and give you all a chance to warn me before I attempt something foolish!

panreyes



cmunoz