Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResolveIPToName implementation is aligned in SynWinSock and SynFPCSock #69

Merged
merged 1 commit into from Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions SynFPCSock.pas
Expand Up @@ -465,8 +465,8 @@ function SetVarSin(var Sin: TVarSin; const IP,Port: string;
Family,SockProtocol,SockType: integer; PreferIP4: Boolean): integer;
function GetSinIP(const Sin: TVarSin): string;
function GetSinPort(const Sin: TVarSin): Integer;
procedure ResolveNameToIP(const Name: string; Family,SockProtocol,SockType: integer;
IPList: TStrings);
procedure ResolveNameToIP(const Name: AnsiString; Family, SockProtocol, SockType: integer;
IPList: TStrings; WillClearIPList: boolean = true);

const
// poll() flag when there is data to read
Expand Down Expand Up @@ -1012,8 +1012,8 @@ function GetSinIP(const Sin: TVarSin): string;
result := '';
end;

procedure ResolveNameToIP(const Name: string; Family, SockProtocol, SockType: integer;
IPList: TStrings);
procedure ResolveNameToIP(const Name: AnsiString; Family, SockProtocol, SockType: integer;
IPList: TStrings; WillClearIPList: boolean = true);
var
Hints: TAddressInfo;
Addr: PAddressInfo;
Expand All @@ -1022,7 +1022,7 @@ procedure ResolveNameToIP(const Name: string; Family, SockProtocol, SockType: in
host, serv: string;
hostlen, servlen: integer;
begin
IPList.Clear;
if (WillClearIPList) then IPList.Clear;
Addr := nil;
try // we force to find TCP/IP
FillChar(Hints, Sizeof(Hints), 0);
Expand Down Expand Up @@ -1148,14 +1148,14 @@ function GetSinIP(const Sin: TVarSin): string;
end;
end;

procedure ResolveNameToIP(const Name: string;
Family,SockProtocol,SockType: integer; IPList: TStrings);
procedure ResolveNameToIP(const Name: AnsiString; Family, SockProtocol, SockType: integer;
IPList: TStrings; WillClearIPList: boolean = true);
var x,n: integer;
a4: array[1..255] of in_addr;
a6: array[1..255] of Tin6_addr;
he: THostEntry;
begin
IPList.Clear;
if (WillClearIPList) then IPList.Clear;
if (family=AF_INET) or (family=AF_UNSPEC) then begin
if lowercase(name)=cLocalHostStr then
IpList.Add(cLocalHost) else begin
Expand Down
2 changes: 1 addition & 1 deletion SynWinSock.pas
Expand Up @@ -1211,8 +1211,8 @@ procedure ResolveNameToIP(const Name: AnsiString; Family, SockProtocol, SockType
Addr := nil;
try
FillChar(Hints, Sizeof(Hints), 0);
Hints.ai_socktype := SockType;
Hints.ai_protocol := SockProtocol;
Hints.ai_socktype := SockType;
r := GetAddrInfo(pointer(Name), nil, @Hints, Addr);
if r = 0 then begin
AddrNext := Addr;
Expand Down