mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-09 21:29:15 +02:00
* htons etc
This commit is contained in:
parent
1cb384eae9
commit
34282c6cf9
@ -170,9 +170,61 @@ begin
|
||||
else
|
||||
Accept:=false;
|
||||
end;
|
||||
|
||||
type thostaddr= packed array[1..4] of byte;
|
||||
|
||||
function htonl( host : longint):longint; {$ifndef VER1_0} inline; {$ENDIF}
|
||||
|
||||
begin
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
htonl:=host;
|
||||
{$else}
|
||||
htonl:=THostAddr(host)[4];
|
||||
htonl:=htonl or ( (THostAddr(host)[3]) shl 8);
|
||||
htonl:=htonl or ( (THostAddr(host)[2]) shl 16);
|
||||
htonl:=htonl or ( (THostAddr(host)[1]) shl 24);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
Function NToHl (Net : Longint) : Longint; {$ifndef VER1_0} inline; {$ENDIF}
|
||||
|
||||
begin
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
ntohl:=net;
|
||||
{$else}
|
||||
ntohl:=THostAddr(Net)[4];
|
||||
ntohl:=ntohl or ( (THostAddr(Net)[3]) shl 8);
|
||||
ntohl:=ntohl or ( (THostAddr(Net)[2]) shl 16);
|
||||
ntohl:=ntohl or ( (THostAddr(Net)[1]) shl 24);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
function htons( host : word):word; {$ifndef VER1_0} inline; {$ENDIF}
|
||||
|
||||
begin
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
htonl:=host;
|
||||
{$else}
|
||||
htons:=swap(host);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
Function NToHs (Net : word):word;{$ifndef VER1_0} inline; {$ENDIF}
|
||||
|
||||
begin
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
ntohs:=net;
|
||||
{$else}
|
||||
ntohs:=swap(net);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.11 2003-11-23 10:57:15 michael
|
||||
Revision 1.12 2004-11-01 16:23:15 marco
|
||||
* htons etc
|
||||
|
||||
Revision 1.11 2003/11/23 10:57:15 michael
|
||||
+ Changed mode to output for file sockets
|
||||
|
||||
Revision 1.10 2003/11/22 21:58:09 marco
|
||||
|
@ -184,9 +184,17 @@ Function Accept(Sock:longint;var addr:TInetSockAddr;var SockIn,SockOut:text):Boo
|
||||
Function Connect(Sock:longint;const addr:TInetSockAddr;var SockIn,SockOut:text):Boolean;
|
||||
Function Connect(Sock:longint;const addr:TInetSockAddr;var SockIn,SockOut:file):Boolean;
|
||||
|
||||
function htonl( host : longint):longint; {$ifndef ver1_0} inline; {$endif}
|
||||
Function NToHl (Net : Longint) : Longint; {$ifndef ver1_0} inline; {$endif}
|
||||
function htons( host : word):word; {$ifndef ver1_0} inline; {$endif}
|
||||
Function NToHs (Net : word):word; {$ifndef ver1_0} inline; {$endif}
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.14 2004-03-16 19:15:57 marco
|
||||
Revision 1.15 2004-11-01 16:23:15 marco
|
||||
* htons etc
|
||||
|
||||
Revision 1.14 2004/03/16 19:15:57 marco
|
||||
* sockaddr is now a union between the old and new struct as grace period
|
||||
|
||||
Revision 1.13 2004/03/16 18:03:37 marco
|
||||
|
Loading…
Reference in New Issue
Block a user