ENIGMA Forums

Contributing to ENIGMA => Function Peer Review => Topic started by: IsmAvatar on September 21, 2010, 12:27:41 pm

Title: Networking on GitHub
Post by: IsmAvatar on September 21, 2010, 12:27:41 pm
I've uploaded my networking files to:
http://github.com/IsmAvatar/EnigmaNet

MIT license, so they can easily be relicensed to GPL.
Please feel free to contribute.

At this time, they are written in C only.
They are largely functional, but some aspects need a bit of improvement, or at least a thorough going-over - in particular, mplay_send and mplay_receive.

They are currently named mplay_ until we get a better name for them. They do not use DirectPlay (which GM uses) and we do not aim to create a reproduction of the mplay_ functionality.

They work standalone, but I'm sure they could be plugged into Enigma as well.
Title: Re: Networking on GitHub
Post by: r9k on September 21, 2010, 01:28:17 pm
We should build an adapter on top of EnigmaNet, while still giving access to the low level functions.

The first thing I'd like to add is a Buffer class that can grows like a vector and be written and read from like a stream.
Title: Re: Networking on GitHub
Post by: r9k on September 21, 2010, 04:55:14 pm
It seems I'm having problems compiling on windows, I'll look into that.
Title: Re: Networking on GitHub
Post by: IsmAvatar on September 21, 2010, 05:55:24 pm
On windows, it has a dependency on WinSock, and you may or may not have to -l it in.
Title: Re: Networking on GitHub
Post by: TheExDeus on September 25, 2010, 11:22:09 am
Quote
They are currently named mplay_ until we get a better name for them. They do not use DirectPlay (which GM uses) and we do not aim to create a reproduction of the mplay_ functionality.
But mplay stands for "multiplayer" as far as I know. So you might as well call them mplay_. I think Enigma should at least replicate GM functions, so creating mplay_ functions with the same parameters would be nice. GM's multiplayer wasn't the best, so no one actually used it, but still. Good work on this thou, and I like the ftp functions. The more functionality there is, the better.
Title: Re: Networking on GitHub
Post by: IsmAvatar on September 25, 2010, 06:57:17 pm
Reproducing those functions is more work than it's worth. I'd basically be creating my own protocol for sessions, player objects, global data objects, and message objects. Not having them is very little loss, especially considering that mplay didn't work 90% of the time for most people anyways, and everyone else switched to GmSock already. Implementing them, on the other hand, is a whole lot of work. Remember that each of those functions has a very specific purpose, so it's not like I could just hand-wave over them. I'd basically have to single-handedly recreate all the work that a large team at Microsoft/DirectX's programming division already did in directplay, and then later decided to scrap and deprecate anyways.
Title: Re: Networking on GitHub
Post by: TheExDeus on September 26, 2010, 09:00:13 am
Ok, I agree.

Also, I didn't imply that you need to write directplay version for Enigma (so it would be as bad as GM one, and so what would be the point?). I just meant that it would be good if functions remained, like mplay_data_write(ind,val), mplay_data_read(ind) and so on. It wouldn't matter what the underlying system is. But as noone used mplay_, then I guess its better to make another system, and net_ prefix suits it.
Title: Re: Networking on GitHub
Post by: Fede-lasse on September 27, 2010, 10:49:55 am
39dll (http://gmc.yoyogames.com/index.php?showtopic=90437) is a good open source networking DLL, so I assume that you've looked into that as well.
Title: Re: Networking on GitHub
Post by: r9k on September 27, 2010, 11:22:50 am
I'm working on it.

http://github.com/r9k/EnigmaNet/ (http://github.com/r9k/EnigmaNet/)

Those are the currently working functions, I tried to do them like GM functions, so it's easier for gm users to use them. Expert users will still be able to use the low level functions.

Code: [Select]
double net_tcp_connect(string ip, unsigned short port, bool blocking);
double net_tcp_connect_timeout(string ip, unsigned short port, bool blocking, float seconds);
bool net_tcp_set_blocking(double tcpsocketId, bool blocking);
double net_tcp_listen(unsigned short port, bool blocking);
double net_tcp_accept(double listener_id, bool blocking);
bool net_tcp_connected(double tcpsocketId);
bool net_tcp_disconnect(double tcpsocketId);
bool net_tcp_send(double tcpsocketId, double packetId);
bool net_tcp_receive(double tcpsocketId, double packetId);
bool net_tcp_destroy(double tcpsocketId);


bool net_udp_bind(unsigned short port, bool blocking);
bool net_udp_bind_available(bool blocking);
bool net_udp_unbind(double udpsocketId);
unsigned short net_udp_localport(double udpsocketId);
bool net_udp_set_blocking(double udpsocketId, bool blocking);
bool net_udp_send(double udpsocketId, double packetId, string ipAddress, unsigned short remotePort);
bool net_udp_receive(double udpsocketId, double packetId, string &ipAddress, unsigned short &remotePort);
bool net_udp_destroy(double udpsocketId);

double net_http_create();
bool net_http_host(double httpId, string host);
double net_http_send(double httpId, double httpRequestId);
bool net_http_destroy(double httpId);
double net_http_request_create();
bool net_http_request_method(double httpRequestId, string method);
bool net_http_request_uri(double httpRequestId, string uri);
bool net_http_request_field(double httpRequestId, string name, string value);
bool net_http_request_body(double httpRequestId, string body);
bool net_http_request_destroy(double httpRequestId);
double net_http_response_status(double httpResponseId);
string net_http_response_body(double httpResponseId);
bool net_http_response_destroy(double httpResponseId);

string net_last_error();

double net_packet_create();
bool net_packet_destroy(double packetId);
template <class T> bool net_packet_write(double packetId, T value);
template <class T> bool net_packet_read(double packetId, T &var);
bool net_packet_clear(double packetId);
double net_packet_size(double packetId);

double net_utility_rc4_create(string keyString);
bool net_utility_rc4_step(double rc4Id);
bool net_utility_rc4_step_add(double rc4Id, double step);
bool net_utility_rc4_step_set(double rc4Id, double step);
char net_utility_rc4_byte(double rc4Id);
bool net_utility_rc4_xor(double rc4Id, double packetId);
bool net_utility_rc4_destroy(double rc4Id);