1

Hello all,
So I'm trying to create a server in which people connect to  it with a client, and then the server handles passing messages around.
Sort of like p2p but with a server acting as middle man.
In BGT, you obviously have the server as part of the network object, using UDP.
The only problem is, BGT does *not* run on linux.
So I thought, no worries, I'll just write the server in c.
But noooo! BGT has some odd network thing going on where it seems to send data to the server, which the BGT server responds too, but c won't because, obviously, it has no idea what the script is chatting about.

My question therefore is:
*is there a way to run bgt in linux
*if not, what exactly does BGT want from the c script to recognise that yes, it has connected?
*can a c server and bgt script even be done/

Thanks a lot.

Nathan Smith
Managing Director of Nathan Tech
It's not disability
It's ability!

Thumbs up

2

Other than running BGT under Wine, I've got nothing.
Things off the top of my head that might be worth doublechecking, if you haven't already done so:

  • BGT network events might be the crux of the issue? They have a type, channel, and message. I don't know how it gets these, if they're inherent to all UDP messages, or what, but I'd try to catch BGT's messages to check, if you can't unravel it otherwise.

  • Just to cover the basics: UDP, right ports, ports are open, etc?

  • The reliable / unreliable thing. The way the manual describes these, sending and receiving reliable packets should involve more work. I would assume the library you're using handles that under the hood, but it's C and it wouldn't surprise me if you're expected to implement the reliability rules. (I swear, 90% of libraries invent the wheel but force every user to reinvent the axle, and I do not understand why.)

Given the choice between mastering networking between platforms, and just doing it all with Windows or Wine... I mean, if I was a Green Lantern, I'd go with the first one, but seeing as I am not...

Some of my games
Keep up to date by following @Jeqofire on twitter!
Ear Ninja?

Thumbs up

3

oh I totally agree!
I actually have wine installed on my linux server... Doesn't mean I can figure out how to freekin' use it. heh

Nathan Smith
Managing Director of Nathan Tech
It's not disability
It's ability!

Thumbs up

4

I recommend using python for both server and client. coding a server which accepts multiple connections in C is really tough. You will need to handle it with threading or multiprocessing, which makes the development on Win32 hard because of the platform difference. You could use some libraries like boost::thread that could absorve the difference though, it would require you other unix-family knowledge to build the library itself. If you use Python, you can write the simplest server and client within 30 to 50 lines. You will still need threading for multiple connections, but doing it in Python is much easier and the code is fully compatible among most platforms.

I really tend to miss direct messages. If you want to contact me privately, please send an email instead of a direct message.

Thumbs up

5

python is very memory heavy, which makes it a poor choice for an efficient server.

Nathan Smith
Managing Director of Nathan Tech
It's not disability
It's ability!

Thumbs up

6

@Nathan: BGT uses ENet under the hood, which is a C library. So if you are working in C you will easily be able to just import that and use its API. Everything else should be handled automatically for you.

Kind regards,

Philip Bennefall

Thumbs up

7

Hi Dardar.
I agree, python can be memory heavy at times, but it has simpler syntax, and you can get things running within an hour or two if your fast.
I can't give you advice about the BGT thing, since I don't use it, but from what I've read in this topic, it sounds simple enough to do this in BGT.

Guitarman.
Playing music and coding, are kinds of real world magic.

Thumbs up

8

@philip_bennefall thanks very much! I'll have a look at that today and update everyone as to how it goes.

Nathan Smith
Managing Director of Nathan Tech
It's not disability
It's ability!

Thumbs up

9

hello
So I must seek wisdom once again.
@phillip
based off of your post, I went and got enet library for c, and installed it. After having a good old laugh at myself, I managed to figure out part of the issue why my code was not compiling.
Anyway, cut a long story short, I opened the UDP port, used the tutorials of enet to design an echo server[had to modify it ever so slightly], used the client from bgt and?
nothing. zilch.

I click connect on the client, it says attempting connection. Sits there for about 10 or so seconds, then says, "Failed to conncet to ."

On the c side, it doesn't register anything is connecting.

What am I doing wroooong! sad

Nathan Smith
Managing Director of Nathan Tech
It's not disability
It's ability!

Thumbs up

10

@9... correction... Python certainly is not memory heavy if you design things correctly. Really though, Python certainly isn't memory heavy -- otherwise it wouldn't be used in half of the Linux distributions today. And some of them do work on low-end systems with less than 384 MB of RAM and python works fine. Hell, Python is even available for the UEFI shell now. If your careful, and know what your doing in Python, your app won't be memory heavy at all. That's like saying C++ is memory heavy -- if you do things right, memory will not be a problem, but if your stupid and don't free memory, memory will be a problem.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

11 (edited by philip_bennefall 2018-02-07 18:30:07)

@Nathan: Just to double check, did you open the port for incoming connections on the server? If you are using localhost for testing, there should generally be no issue there but it never hurts to double check. Another potential source of issues is incompatible versions; BGT uses an old version of ENet. To make sure you are compatible, go grab ENet version 1.3.1 and build using that.

Kind regards,

Philip Bennefall

Thumbs up