[BETA] SA:MP Sockets Plugin R2 -
StrickenKid - 27.08.2010
SA:MP Sockets Plugin
Beta R2
Beta:
This is a BETA version, which means its not fully complete and stable, so, please post any bugs and errors you find!
ChangeLog:
- 8/28/2010 - BETA R2:
- Fixed some small coding errors.
- Fixed error which caused the plugin to issue false errors with socket_send.
- Fixed receive error which was caused by the buffer being too large.
- Fixed spelling error with OnSocketReceive callback.
- Added socket_stoplistening to stop listening for connections.
- Added port param to OnSocketConnect callback.
- Added port param to OnSocketReceive callback.
Thanks to ev0lutionn for catching most of the bugs!
About:
A couple months ago, I was experimenting with socket compatibilities through a SA:MP plugin (because dgram through SA:MP doesn't work). I completed the plugin a while back but I've put off releasing it because I was never able to find the time to test the plugin thoroughly. So, I've just decided to let you, the SA:MP community help do the testing! This plugin allows a SA:MP server to connect to TCP sockets, sending and receiving information from one server to another, or from a server to a client. You can either listen for sockets, or connect to a socket. For example: You could connect multiple SA:MP server's chats together, or create a custom rcon panel, or pretty much anything else.
How To Install:
- Windows:
- Download the plugin.
- Place the sockets.dll in your plugins folder.
- Open your server.cfg and add "sockets" to "plugins", if there is no "plugins" line, add one.
- Add sockets.inc to your /pawno/includes/ and add "#include <sockets>" to the top of your script.
- Linux:
- Download the plugin to your linux server.
- Place the sockets.so in your plugins folder.
- Open your server.cfg and add "sockets.so" to "plugins", if there is no "plugins" line, add one.
- On the PC that you compile your script on, add sockets.inc to your /pawno/includes/ and add "#include <sockets>" to the top of your script.
Functions:
- native socket_startlistening(port);
- Use this function to start listening for sockets on the selected port.
- native socket_stoplistening();
- Use this function to stop listening for sockets.
- native socket_connect(ip[], port);
- Use this function to connect to a socket server listening for connections.
- native socket_send(data[]);
- Use this function to send data to the connected socket.
- native socket_close();
- Use this function to close the connection of the current connected socket.
Callbacks:
- forward OnSocketConnect(address[], port)
- This callback gets called when a socket is accepted to the listening server.
- forward OnSocketRecieve(data[], address[], port)
- This callback gets called when data has been received from the connected socket.
Downloads (BETA R2):
- Windows (.NET Framework required)
- Linux (compiled on Debian 5)
- Source
- Scripts
Want To Compile It Yourself?
- Windows:
- Visual Studio 2008 Required
- Open the project file and click Build>Build Solution or press F7
- Linux:
- make, gcc and g++ required
- cd to the directory the plugin files are in and simply type "make"
Post Comments And Questions!
Re: [BETA] SA:MP Sockets Plugin -
Fj0rtizFredde - 27.08.2010
Sweet
Im going to test it when I come home
Re: [BETA] SA:MP Sockets Plugin -
Flake. - 27.08.2010
another great release thanks
Re: [BETA] SA:MP Sockets Plugin -
Blacklite - 27.08.2010
Quote:
Originally Posted by Micheliano
You could connect multiple SA:MP server's chats together
|
That's EXACTLY what we did when testing it =]
Good work SK!
Re: [BETA] SA:MP Sockets Plugin -
pliva_sb - 27.08.2010
Quote:
Originally Posted by Blacklite
That's EXACTLY what we did when testing it =]
Good work SK!
|
Really good work,I also work with socket as plugin but I don't have this idea.
Does it support multiconnection?
Did you test send a value?I think that isn't possible in this version.
Re: [BETA] SA:MP Sockets Plugin -
armyoftwo - 27.08.2010
Can you create something like this with this plugin?
If yes it's amazing!!! [url..]http://www.youtube.com/watch?v=ZO_QtORVXdc[/.url]
Re: [BETA] SA:MP Sockets Plugin -
Blacklite - 27.08.2010
Quote:
Originally Posted by armyoftwo
Can you create something like this with this plugin?
If yes it's amazing!!! [url..]http://www.youtube.com/watch?v=ZO_QtORVXdc[/.url]
|
That's a different project, has nothing to do with this plugin.
Re: [BETA] SA:MP Sockets Plugin -
MrDeath537 - 27.08.2010
Wooow, nice release.
Your plugins are always nice
Re: [BETA] SA:MP Sockets Plugin -
ev0lution - 27.08.2010
The functions and callbacks provided confuse me.
If you listen on a port with socket_startlistening, will it accept any socket connections from any source, or only from other servers running this plugin and using socket_connect. Will it also call OnSocketConnect and OnSocketRecieve (which should be OnSocketRec
eive) as normal?
@Blacklite: I don't think you realised Micheliano quoted StrickenKid, he said that in the original post. (and I'm guessing you tested it with him)
EDIT: When trying to bind to the server port (7777) I got "Error: Function: start_listening is already listening. Error id: 2" upon calling the function, then "[Socket] Started listening on port 7777." after the gamemode had loaded. (I'm using it in a filterscript)
Re: [BETA] SA:MP Sockets Plugin -
nielsbon1 - 27.08.2010
W00t nice this will come very handy! Thanks
Re: [BETA] SA:MP Sockets Plugin -
Kyosaur - 27.08.2010
This makes me wonder why the datagram was removed in the first place. *shrugs*
I cant honestly say i see a good use for this, but regardless nice job.
Re: [BETA] SA:MP Sockets Plugin -
WillyP - 27.08.2010
blacklite and sk are pwnage but bob is just hawt <3
Re: [BETA] SA:MP Sockets Plugin -
Scenario - 27.08.2010
This will help me in the future a lot!
Thank you! I'll be testing and reporting all bugs I find!
Re: [BETA] SA:MP Sockets Plugin -
Dark_Kostas - 27.08.2010
Quote:
Originally Posted by ev0lutionnn
EDIT: When trying to bind to the server port (7777) I got "Error: Function: start_listening is already listening. Error id: 2" upon calling the function, then "[Socket] Started listening on port 7777." after the gamemode had loaded. (I'm using it in a filterscript)
|
if your server port is 7777 too then i dont think you can do it.
Re: [BETA] SA:MP Sockets Plugin -
CJ101 - 27.08.2010
i was just thinking, could this listen on port 21 and auto-restart the server when a new .amx is uploaded?
Re: [BETA] SA:MP Sockets Plugin -
Victor - 27.08.2010
Quote:
Originally Posted by CoaPsyFactor
you can hack servers with this
|
offtopic: ....
OnTopic: Nice plugin I can make use of this
Re: [BETA] SA:MP Sockets Plugin -
Toni - 27.08.2010
Very nice, But I have a question, as Armyoftwo posted that link...is it possible to create custom dialogs to chat like that in SA:MP?
Re: [BETA] SA:MP Sockets Plugin - [L3th4l] - 27.08.2010
Nice, i have seen similar types of abilities on my friends server.
Re: [BETA] SA:MP Sockets Plugin -
nemesis- - 28.08.2010
The possibilities with a plugin of this nature are endless.
Re: [BETA] SA:MP Sockets Plugin -
ev0lution - 28.08.2010
Some problems, from a Windows server:
1. Occasionally the plugin returns WSA error code 10004 or 10038 - usually with 10004 the function called works as normal
2. Occasionally the plugin claims that socket_send fails, or that the "last receive failed", when neither do, and they both actually work
3. If a client connects, sends something to the server and disconnects, the plugin doesn't handle it fast enough, and crashes after "Client x closed the connection" (before it calls OnSocketRecieve)
4. Unless I'm missing something, the plugin seems to only ever send 4 bytes per socket_send call. For example, I connected via a PHP script (the client) and wrote 12 bytes to the socket. The server-side script uses socket_send to send "thisisatest" back to the connected client. The connected client receives "test". It seems to be the same with any string sent.. only 4 bytes are sent.
Great plugin though, I'm using it for a project now which wouldn't have been possible without it. Very useful, just needs a few bugs fixed. :P