Synsock - correct port byte ordering on Win and Posix

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@224 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
geby 2021-06-15 14:47:23 +00:00
parent 77ee03bf28
commit 9c92358b29
2 changed files with 6 additions and 6 deletions

View File

@ -1031,7 +1031,7 @@ begin
if ServEnt = nil then
Result := StrToIntDef(Port, 0)
else
Result := htons(ServEnt^.s_port);
Result := ntohs(ServEnt^.s_port);
finally
SynSockCS.Leave;
end;
@ -1049,9 +1049,9 @@ begin
if (r = 0) and Assigned(Addr) then
begin
if Addr^.ai_family = AF_INET then
Result := htons(Addr^.ai_addr^.sa_data[0]); // port
Result := ntohs(Addr^.ai_addr^.sa_data[0]); // port
if Addr^.ai_family = AF_INET6 then
Result := htons(PSockAddrIn6(Addr^.ai_addr)^.sin6_port);
Result := ntohs(PSockAddrIn6(Addr^.ai_addr)^.sin6_port);
end;
finally
if Assigned(Addr) then

View File

@ -1452,7 +1452,7 @@ begin
if ServEnt = nil then
Result := StrToIntDef(string(Port), 0)
else
Result := synsock.htons(ServEnt^.s_port);
Result := synsock.ntohs(ServEnt^.s_port);
finally
SynSockCS.Leave;
end;
@ -1470,9 +1470,9 @@ begin
if (r = 0) and Assigned(Addr) then
begin
if Addr^.ai_family = AF_INET then
Result := synsock.htons(Addr^.ai_addr^.sin_port);
Result := synsock.ntohs(Addr^.ai_addr^.sin_port);
if Addr^.ai_family = AF_INET6 then
Result := synsock.htons(PSockAddrIn6(Addr^.ai_addr)^.sin6_port);
Result := synsock.ntohs(PSockAddrIn6(Addr^.ai_addr)^.sin6_port);
end;
finally
if Assigned(Addr) then