Jump to content

[REL] Socket Module (TCP/UDP) (Server/Client)


laserlaser

Recommended Posts

Module:Sockets

I proudly present you ml_sockets a c++ extension for mta 1.0, it was made by BlueG for SAMP and translated to MTA by me.

The module adds socket functions & events to mta, sockets are used for communication between computers.

See wikipedia for more info: http://en.wikipedia.org/wiki/Internet_socket

Installation:

- download ml_sockets (https://rapidshare.com/files/2826542902/ml_sockets.zip)

- unzip

- place ml_sockets in (..server\mods\deathmatch\modules)

- add the module to your mtaserver.conf ( or for linux)

- restart the server or write to console "loadmodule ml_sockets(.dll,.so)"

Functions:

  
int socket_create(int protocolType); -- udp & tcp , 1:TCP, 2:UDP -> Returns socket_id 
bool socket_bind(int socket_id, string ip); -- udp & tcp 
bool socket_connect(int socket_id, string host, int port); -- udp & tcp 
bool socket_listen(int socket_id, int port); -- udp & tcp 
bool socket_stop_listen(int socket_id); -- udp & tcp 
bool socket_destroy(int socket_id); -- udp & tcp 
bool socket_send(int socket_id, string data, int len); -- udp & tcp 
bool is_socket_valid(int socket_id); -- udp & tcp 
bool socket_set_max_connections(int socket_id, int max_remote_clients); -- tcp only 
bool socket_close_remote_client(int socket_id, int remote_clientid); -- tcp only 
bool socket_sendto_remote_client(int socket_id, int remote_clientid, string data); -- tcp only 
bool socket_remote_client_connected(int socket_id, int remote_clientid); -- tcp only 
string get_remote_client_ip(int socket_id, int remote_clientid); -- tcp only 
  

Events:

  
-- client & server (udp) 
onUDPReceiveData(int socket_id, string data, data_len, string remote_client_ip, int remote_client_port); 
-- client only (tcp) 
onSocketAnswer(int socket_id, string data, int data_len); -- called when socket_connect() has been used and the server sends data 
onSocketClose(int socket_id); 
-- server only (tcp) 
onSocketReceiveData(int socket_id, int remote_clientid, string data, int data_len); -- called when a remote client sends data 
onSocketRemoteConnect(int socket_id, string remote_client, int remote_clientid); -- called when a remote client connects to our socket server 
onSocketRemoteDisconnect(int socket_id, int remote_clientid); -- called when a remote client disconnects from our socket server 
  
Both of all events source always N/A 
  

Tutorials will be added soon.

I will be include this to my javaSDK for callJava

Link to comment
  • 3 months later...
  • 4 weeks later...

thanks for link =) but i have a problem with this module

my steps:

1) copied ml_sockets.dll in to the folder modules

2) server.config:

3) startet the server

now i get this error: [2013-01-03 10:08:20] MODULE: Unable to find modules/ml_sockets.dll!

can you help me?

in use the mta_mysql.dll module too, and this is working fine

Link to comment
  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...