latest version: http://forums.alliedmods.net/attachm...chmentid=83286
This extension provides networking functionality for SourceMod scripts. It's a heavily modified fork of Olly's sockets extension 2.0.0.
It's supposed to be stable. If it crashes please post the srcds debug.log and the plugin's sourcecode which makes use of the socket extension.
You need at least SourceMod 1.0.3!
Look at socket.inc for development documentation.
Developer Notes
- Make sure to use all 3 Set...Callback functions on sockets spawned by listen sockets before using the child sockets.
- Don't use ports below 1024 for listening sockets due to permission restrictions on linux
- Do not expect SocketConnect() and SocketSend() to be atomic operations, both might not have finished yet after they were executed. Always use the socket connect-callback as shown in the example to start sending data.
- Don't forget to close the socket handle
Usage example
The example example.sp downloads a file via http to
<modfolder>/dl.htm
The example listenexample.sp provides a simple echo server. Use telnet
<serverip> 50000 to connect to it.
The examples are located at addons/sourcemod/scripting in the socket.zip file.
Changelog
Version 2.4.0+- check the git(web) shortlog (see sourcecode repository url)
Version 2.3.1
- fixed an error handling bug
Version 2.3.0- Added SocketDisconnect()
- fixed a crashbug on unload
- fixed receiving binary data
- improved error handling
- stricter condition checking
- fixed a possible race condition in SocketSetSendqueueEmptyCallback()
Version 2.2.0- Added optional SendqueueEmpty callback which allows an application to correctly close the connection after all data has been sent
- Fixed SocketSend() calculating the packet size 1 byte too large if it was not specified explicitly (thx to olly for finding the bug)
Version 2.1.0- Added SocketSetOption()
- Added optional packet/callback concatenation mechanism to reduze the amount of receive callbacks for large transfers
- removed Metamod:Source dependency (-> AddGameFrameHook)
- improved sending of large chunks of data
- everything should be binary safe now (support for sending/receiving 0x00), read the documentation for details
- moved sending and connecting into threads
- a few bugfixes
Version 2.0.0- Added SocketBind() and SocketListen() -> listening socket support
- major API change to unify and optimize the socket usage
- some additional small changes
Version 1.0.0
Sourcecode repository
http://player.to/gitweb/index.cgi?p=sm-ext-socket.git
- Clone my public repository:
git clone git://player.to/sm-ext-socket.git <directory>
Download
latest version: http://forums.alliedmods.net/attachm...chmentid=83286