[Plugin] [BETA] SA:MP Sockets Plugin
#1

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:
    1. Download the plugin.
    2. Place the sockets.dll in your plugins folder.
    3. Open your server.cfg and add "sockets" to "plugins", if there is no "plugins" line, add one.
    4. Add sockets.inc to your /pawno/includes/ and add "#include <sockets>" to the top of your script.
  • Linux:
    1. Download the plugin to your linux server.
    2. Place the sockets.so in your plugins folder.
    3. Open your server.cfg and add "sockets.so" to "plugins", if there is no "plugins" line, add one.
    4. 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):
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!
Reply
#2

Sweet Im going to test it when I come home
Reply
#3

another great release thanks
Reply
#4

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!
Reply
#5

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.
Reply
#6

Can you create something like this with this plugin?
If yes it's amazing!!! [url..]http://www.youtube.com/watch?v=ZO_QtORVXdc[/.url]
Reply
#7

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.
Reply
#8

Wooow, nice release.

Your plugins are always nice
Reply
#9

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 OnSocketReceive) 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)
Reply
#10

W00t nice this will come very handy! Thanks
Reply
#11

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.
Reply
#12

blacklite and sk are pwnage but bob is just hawt <3
Reply
#13

This will help me in the future a lot! Thank you! I'll be testing and reporting all bugs I find!
Reply
#14

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.
Reply
#15

i was just thinking, could this listen on port 21 and auto-restart the server when a new .amx is uploaded?
Reply
#16

Quote:
Originally Posted by CoaPsyFactor
Посмотреть сообщение
you can hack servers with this
offtopic: ....

OnTopic: Nice plugin I can make use of this
Reply
#17

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?
Reply
#18

Nice, i have seen similar types of abilities on my friends server.
Reply
#19

The possibilities with a plugin of this nature are endless.
Reply
#20

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)