Script Name: SocketCore
Script Description SocketCore to handle socket based connections.
Author: DualCompile Test: Failed. Error Detected.Core Version: 3.0
Hosted by: Soldat Central - http://soldatcentral.com/Usage:function InitSocket(const IP: string; const Port: integer; const ReconTime: word; const Retries: integer): integer;Initializes a new socket and connects it to the given IP & Port.
ReconTime specifies a time in milliseconds to wait before trying to reconnect if the remote host disconnected.
Set Retries to -1 for no limit of reconnect attempts.
The function returns an integer value which will be your handle for OnPacketReceived, WriteLnSocket and OnDisconnect.
In case the return value is -1, the socket failed to connect to the remote host and the socket instance will be destroyed.
procedure OnPacketReceived(const Handle: integer; const Packet: string);Use this procedure for any data parsing events. It will be called whenever a new packet has been received.
Handle will be the socket which received the packet.
function WriteLnSocket(const Handle: integer; const Packet: string): boolean;Sends a line to the remote host. If the line has been sent, the function will return true.
procedure OnDisconnect(const Handle: integer);This procedure will be called whenever a remote host disconnected.
Handle will be the disconnected socket.
I especially want to say thanks to dnmr` for helping and improving the script.
If you find any bugs, let me know. Last but not least make sure you have turned off the safe mode before running this script.