16.06.2011, 02:18
(
Последний раз редактировалось langricr; 17.06.2011 в 03:46.
Причина: Version 1.2 + Better image
)
WinSock Plugin - Beta 1.2
This plugin is a functioning, windows-only socket plugin I designed as per a friend's request. This plugin uses assigned IDs to manage multiple connections simultaneously, it uses threading for reading and listening and the main thread for sending data and connecting.
This plugin supports only one connection per socket at any given time, once a connection is accepted by a listening socket it will turn into an active socket, an active socket must be disconnected before it can connect or listen for another connection.
Big credit to StrickenKid for releasing the source to some of his work, an effective tutorial in its own rights.
This version only works under Windows operating systems with support for WinSock 2.2. Modifying it to be cross-platform compatible is currently being considered.
Functions
Callbacks

Changelog
Version 1.2
This plugin is a functioning, windows-only socket plugin I designed as per a friend's request. This plugin uses assigned IDs to manage multiple connections simultaneously, it uses threading for reading and listening and the main thread for sending data and connecting.
This plugin supports only one connection per socket at any given time, once a connection is accepted by a listening socket it will turn into an active socket, an active socket must be disconnected before it can connect or listen for another connection.
Big credit to StrickenKid for releasing the source to some of his work, an effective tutorial in its own rights.
This version only works under Windows operating systems with support for WinSock 2.2. Modifying it to be cross-platform compatible is currently being considered.
Functions
pawn Код:
native socket_create( id );
// Used to create a socket to be used by the plugin, only one socket with this ID can be used at any given time.
native socket_destroy( id );
// Used to destroy a socket, this will first call the disconnect function and then the ID will be available for use again.
native socket_connect( id, ip[], port);
// Used to make the inactive socket connect to a remote IP address's port.
native socket_disconnect( id );
// Used to make an active socket close.
native socket_send( id, data[] );
// Used to send data over an active socket.
native socket_listen( id, port );
// Used to make the socket listen for an incoming connection on the specified port.
native socket_stoplisten( id );
// Used to make the socket stop listening.
native socket_id_available( id );
// Returns true if the ID is not in use, false otherwise.
native socket_isactive( id );
// Returns true if the ID is in use, false if otherwise or not found
native socket_islistening( id );
// Returns true if the ID is listening, false if otherwise or not found
native socket_getbuffersize( id );
// Returns the size of the socket's buffer
native socket_setbuffersize( id, size );
// Returns true if the buffer size has been set, false otherwise or not found
native socket_cleanstring( source[], dest[] );
// Creates a copy of the source string with all non-printable characters stripped.
pawn Код:
forward onSocketConnect( id, ip[], port );
// Called when a socket connects to a remote host, or when a listening socket accepts a connection and becomes an active socket. The IP and port belong to the remote host.
forward onSocketDisconnect( id );
// Called when a socket disconnects, either on the host or server's end.
forward onSocketReceive( id, data[] );
// Called when a socket receives data from the remote host.

Changelog
Version 1.2
- + added the ability to specify the buffer size per socket
- + added socket_getbuffersize( id )
- + added socket_setbuffersize( id, size )
- + added a function to return a string stripped of non-printable characters
- + added socket_cleanstring( source[], dest[] )
- - removed automatic filtration of non-printable characters
- - removed a debug message that got left in version 1.1
- + added ProcessTick support
- + added socket_isactive( id )
- + added socket_islistening( id )
- + added some comments to the SampSocket class, planning more
- + added credit where credit is due
- = moved the core code around a lot