Hi every delphi coders!
I've made an update of SocketUnitEx. It working fine on newer PureRAT versions.
Just few steps to make PureRAT client part more stable and start posting binaries release

Code:
{
  ---------------------------------------------------

  SocketUnitEx.pas v1.1
	Original unit by Aphex -> unremote@knology.net
	Modified by Wr #!d3 -> Wrh1d3@gmail.com

  ---------------------------------------------------

  This update was made for working on PureRAT v7.0
  It only contain TClientSocket class, so don't be
  confused with some specifics functions!

  ---------------------------------------------------
  
  As all open source software, you can redistribute,
  modify code, ... But don't forget to give credits :)

  ---------------------------------------------------

  Modified by Wr #!d3 Monday 5th May 2016 6:50:03 PM

  ---------------------------------------------------
}

unit SocketUnitEx; 

interface

uses
  Windows, Winsock;

type
  TClientSocket = class(TObject)
  private
		FSocket: TSocket;
    FConnected: Boolean;
  public
    constructor Create;
    destructor Destroy; override;
    procedure Connect(Host: string; Port: Word);
    procedure SetIdle;
    function LocalAddress: string;
		function RemoteAddress: string;
		function LocalPort: Word;
    function RemotePort: Word;
    function SendBuffer(var Buffer; BufferSize: Integer): Integer;
    function RecvBuffer(var Buffer; BufferSize: Integer): Integer;
    function SendText(const Text: string): Integer;   
    function ReceiveText: string;
    property Socket: TSocket read FSocket;
    property Connected: Boolean read FConnected;
  end;
	
implementation

var
	WSAData: TWSAData;

//Variable Initialization
constructor TClientSocket.Create;
begin    
	inherited Create;
  FSocket := INVALID_SOCKET;
  FConnected := False;
end;

//Clearing initialized variable
destructor TClientSocket.Destroy;
begin
	shutdown(FSocket, SD_BOTH);
  closesocket(FSocket);
	FSocket := INVALID_SOCKET;
  FConnected := False;
  inherited Destroy;
end;

//Function for connecting to server
procedure TClientSocket.Connect(Host: string; Port: Word);
var
  SockAddrIn: TSockAddrIn;
  HostEnt: PHostEnt;
begin
  FSocket := WinSock.socket(AF_INET, SOCK_STREAM, 0); //You can change socket type
  if FSocket = INVALID_SOCKET then Exit; //Stop connecting action if INVALID_SOCKET
                                         //So FConnected value will stay to False

  SockAddrIn.sin_family := AF_INET;
	SockAddrIn.sin_port := htons(Port);
  SockAddrIn.sin_addr.S_addr := inet_addr(PChar(Host));

  //Resolving ip address
	if SockAddrIn.sin_addr.s_addr = INADDR_NONE then
  begin
    HostEnt := gethostbyname(PChar(Host));
    if HostEnt = nil then Exit;
    SockAddrIn.sin_addr.s_addr := Longint(PLongint(HostEnt^.h_addr_list^)^);
  end;
	                                   
  if WinSock.connect(FSocket, SockAddrIn, SizeOf(SockAddrIn)) = 0 then FConnected := True;
  //Set FConnected True only if connected
end;

procedure TClientSocket.SetIdle; //This function is useful when etablishing connection to server
var                              //Thanks to SpyNet coders for this trick!
  FDset: TFDset;
  TimeVal: TTimeVal;
begin
  FD_ZERO(FDSet);
  FD_SET(FSocket, FDSet);
  select(0, @FDset, nil, nil, nil);
end;

function TClientSocket.LocalAddress: string;
var
  SockAddrIn: TSockAddrIn;
  Size: integer;
begin
  Size := sizeof(SockAddrIn);
  getsockname(FSocket, SockAddrIn, Size);
  Result := inet_ntoa(SockAddrIn.sin_addr);
end;

function TClientSocket.RemoteAddress: string;
var
  SockAddrIn: TSockAddrIn;
  Size: Integer;
begin
  Size := sizeof(SockAddrIn);
  getpeername(FSocket, SockAddrIn, Size);
  Result := inet_ntoa(SockAddrIn.sin_addr);
end;

function TClientSocket.LocalPort: Word;
var
  SockAddrIn: TSockAddrIn;
  Size: Integer;
begin
  Size := sizeof(SockAddrIn);
  getsockname(FSocket, SockAddrIn, Size);
  Result := ntohs(SockAddrIn.sin_port);
end;

function TClientSocket.RemotePort: Word;
var
  SockAddrIn: TSockAddrIn;
  Size: Integer;
begin
  Size := sizeof(SockAddrIn);
  getpeername(FSocket, SockAddrIn, Size);
  Result := ntohs(SockAddrIn.sin_port);
end;

//Big changes was made on these two following functions
function TClientSocket.SendBuffer(var Buffer; BufferSize: Integer): Integer;
begin
  Result := send(FSocket, Buffer, BufferSize, 0);
end;
   
function TClientSocket.RecvBuffer(var Buffer; BufferSize: Integer): Integer;
begin
  //ioctlsocket set Result length to received data size
  //Don't remove this line!
  if BufferSize = -1 then ioctlsocket(FSocket, FIONREAD, Longint(Result)) else
  Result := recv(FSocket, Buffer, BufferSize, 0); //Write received datas to Buffer
end;

function TClientSocket.SendText(const Text: string): Integer;
begin
  Result := SendBuffer(Pointer(Text)^, Length(Text));
end;
  
function TClientSocket.ReceiveText: string;
begin
  SetLength(Result, RecvBuffer(Pointer(nil)^, -1)); //First set Result length to received data size.
  SetLength(Result, RecvBuffer(Pointer(Result)^, Length(Result)));
end;

//Don't remove following lines!
initialization
	WSAStartup($0101, WSAData); //You can change winsock version  

finalization
  WSACleanup();

end.