Einzelnen Beitrag anzeigen

pertzschc

Registriert seit: 29. Jul 2005
Ort: Leipzig
305 Beiträge
 
Delphi 10.4 Sydney
 
#5

AW: Suche WSocket unit für D2010 (Unicode)

  Alt 14. Nov 2013, 14:09
Jetzt habe ich es:
Delphi-Quellcode:
function TCustomWSocket.GetLocalHostAddress: string;
var
  SockAddrIn: TSockAddrIn;
  HostEnt: PHostEnt;
  szHostName: array[0..128] of AnsiChar;
begin
  if gethostname(szHostName, SizeOf(szHostName)) = 0 then
  begin
    HostEnt := gethostbyname(szHostName);
    if HostEnt = nil then
      Result := ''
    else
    begin
      SockAddrIn.sin_addr.S_addr := longint(plongint(HostEnt^.h_addr_list^)^);
      Result := inet_ntoa(SockAddrIn.sin_addr);
    end;
  end
  else
    SocketError(WSAGetLastError);
end;
  Mit Zitat antworten Zitat