1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-10-31 23:45:13 -04:00

Merge branch 'SocketInfo' of https://github.com/Dgby714/Simba into Dgby714-SocketInfo

This commit is contained in:
Merlijn Wajer 2011-01-15 10:46:09 +01:00
commit 175b685357
3 changed files with 13 additions and 0 deletions

View File

@ -107,6 +107,11 @@ begin
Result := CurrThread.Socks.CreateSocketEx(CurrThread.Socks.GetSocket(Client).Accept); Result := CurrThread.Socks.CreateSocketEx(CurrThread.Socks.GetSocket(Client).Accept);
end; end;
procedure ps_SocketInfo(Client: integer; out IP, Port: string);
begin
CurrThread.Socks.GetSocket(Client).Info(IP, Port);
end;
function ps_CreateSocket: integer; extdecl; function ps_CreateSocket: integer; extdecl;
begin begin
Result := CurrThread.Socks.CreateSocket(); Result := CurrThread.Socks.CreateSocket();

View File

@ -280,6 +280,7 @@ AddFunction(@ps_RecvSocketStr, 'function RecvSocketStr(Client: integer): string;
AddFunction(@ps_RecvSocketEx, 'function RecvSocketEx(Client, Length: integer): string;'); AddFunction(@ps_RecvSocketEx, 'function RecvSocketEx(Client, Length: integer): string;');
AddFunction(@ps_SendSocket, 'procedure SendSocket(Client: integer; Data: string);'); AddFunction(@ps_SendSocket, 'procedure SendSocket(Client: integer; Data: string);');
AddFunction(@ps_SetSocketTimeout, 'procedure SetTimeout(Client, Time: integer);'); AddFunction(@ps_SetSocketTimeout, 'procedure SetTimeout(Client, Time: integer);');
AddFunction(@ps_SocketInfo, 'procedure SocketInfo(Client: integer; out IP, Port: string);');
{$ENDIF} {$ENDIF}
{ Color Conversions and Speed } { Color Conversions and Speed }

View File

@ -64,6 +64,7 @@ type
procedure Bind(IP, Port: string); procedure Bind(IP, Port: string);
procedure Listen; procedure Listen;
function Accept: TTCPBlockSocket; function Accept: TTCPBlockSocket;
procedure Info(out IP, Port: string);
constructor Create(Owner: TObject; Socket: TTCPBlockSocket = nil); constructor Create(Owner: TObject; Socket: TTCPBlockSocket = nil);
destructor Destroy; override; destructor Destroy; override;
end; end;
@ -420,6 +421,12 @@ begin
raise Exception.Create('Socket Error ' + IntToStr(Sock.LastError) + ': ' + Sock.LastErrorDesc); raise Exception.Create('Socket Error ' + IntToStr(Sock.LastError) + ': ' + Sock.LastErrorDesc);
end; end;
procedure TSock.Info(out IP, Port: string);
begin
IP := Sock.GetRemoteSinIP;
Port := IntToStr(Sock.GetRemoteSinPort);
end;
constructor TSock.Create(Owner: TObject; Socket: TTCPBlockSocket = nil); constructor TSock.Create(Owner: TObject; Socket: TTCPBlockSocket = nil);
begin begin
inherited Create; inherited Create;