Hi,
I have made this extension so that your server can communicate with other servers, and send and receive data between them. This can be used for downloading through HTTP, creating an irc bot, querying another game server.. List goes on
Any bugs then get me in #sourcemod
Credits:
BAILOPAN, PimpinJuice, devicenull, and anyone else i missed from #sourcemod
Install:
1. Extract 'sockets.ext.dll' to the 'addons/sourcemod/extensions' folder.
2. Extract 'sockets.inc' to the 'addons/sourcemod/scripting/include' folder.
WINDOWS ONLY AT THE MOMENT, LINUX WILL BE TOMOROW
Changed Natives:
/**
* Creates a new socket.
*
* @param protocol The type of socket to create, TCP (default), or UDP
* @param SocketRecieve:rfunc The recieve callback.
* @param SocketError:efunc The error callback.
* @return Handle The socket handle. Returns INVALID_HANDLE on failure
*/
native Handle:CreateSocket(SocketType:protocol=SOCKE T_TCP, SocketRecieve:rfunc, SocketError:efunc);
This has now changed, the SocketRecive, and SocketError callbacks are now paramaters of this native.
/**
* Convert a string to an MD5 hash (used for irc-relay)
*
* @param String:input The input string
* @param String
utput The output string
* @param size The length of the output buffer
*/
native md5HashString(String:in[], String
ut[], size);
This has nothing todo with sockets, but i needed in in IRC-Relay because SQLite sucks balls
public(String:recieveData[], const dataSize, Handle:arg)
The socketrevieve callback signature is now as above
Plugin Example
I couldnt be bothered to write a new example plugin. But you can check my new IRC Relay which i will be posting after this.
Enjoy
Change Log
Quote:
1.0.0.0- Initial Release
1.0.0.1- Minor changes (never released)
1.0.1.0- Huge overhaull of everything in the plugin (consider this the first release)
1.0.2.0- Fixed lots of null pointer crashes ><
- Fixed the native name in the include for SocketClose
- Fixed functag
- Compiled for linux
1.2.0.0- Skipped a load of version numbers (because i can)
- Added SetConnectedCallback, and SetDisconnectCallback
- CreateSocket now returns a Handle type which needs to be passed to all natives
- Removed lots of the BS comments
- Hopefully fixed lots of crashes in linux
- Added arg argument for all callbacks to identify the socket that called back
2.0.0
- Fixed lots of bugs
- Fixed problem with the way i setup the callbacks (thanks bailo)
- Changed the way that the natives work, less 'set callack' natives, so it works much better
- The SocketReceive native now has the data that was got from the socket in one of the paramaters, instead of needing to specify a global string of a fixed size.
- Compiled for Orange-Box
|