Unit Sockets

From Ultibo.org
Jump to: navigation, search

Return to Unit Reference


Description


Ultibo Network Sockets Interface unit

This unit incorporates the socketsh.inc header from rtl-extra and adds Ultibo specific functionality. The unit can then be used in place of the sockets unit normally provided by the rtl-extra package.

Notes: All BSD functions that accept an Address or Port expect them to be in Network order. All other functions that take an Address or Port expect them to be in Host order

This unit includes the interface normally provided by the sockets unit in the FPC package rtl-extras. The rtl-extras package does not build the sockets unit for target Ultibo as this unit will always be available to provide the required functionality for any other package that uses it.

Constants



[Expand]
Sockets specific constants SOCKETS_*


[Expand]
Socket error Esock*, EAI_*


[Expand]
Socket shutdown option SHUT_*


[Expand]
Socket type SOCK_*


[Expand]
Socket input and output S_IN*


[Expand]
Address family AF_*


[Expand]
Protocol family PF_*


[Expand]
IP protocol IPPROTO_*


[Expand]
IP port IPPORT_*


[Expand]
IP option IP_*


[Expand]
Socket option SO_*


[Expand]
TCP option TCP_*


[Expand]
UDP option UDP_*


[Expand]
Message flag MSG_*


[Expand]
Address info flag AI_*


[Expand]
Name info flag NI_*


Type definitions



Sockets device event

[Expand]

PSocketsDeviceEvent = ^TSocketsDeviceEvent;

TSocketsDeviceEvent = record

Numeric types

sa_family_t = cushort;

Integer types

size_t = GlobalTypes.SIZE_T; cuint32;
ssize_t = GlobalTypes.SSIZE_T; cint32;

Socket length

tsocklen = cint;
psocklen = ^tsocklen;

IPv4 address

pin_addr = ^in_addr;
in_addr = GlobalSock.in_addr;
TIn_addr = in_addr;
TInAddr = GlobalSock.TInAddr;
PInAddr = GlobalSock.PInAddr;

Internet socket address

TInetSockAddr = sockaddr_in;
PInetSockAddr = psockaddr_in;

Socket address

psockaddr = GlobalSock.psockaddr;
sockaddr = GlobalSock.TSockAddr;
TSockAddr = GlobalSock.TSockAddr;
psockaddr_in = ^sockaddr_in;
sockaddr_in = GlobalSock.sockaddr_in;

FD set type

TFDSet = GlobalSock.TFDSet;
PFDSet = GlobalSock.PFDSet; Legacy

Time value

PTimeVal = GlobalSock.PTimeVal;
TTimeVal = GlobalSock.TTimeVal;

Linger

plinger = GlobalSock.plinger;
linger = GlobalSock.linger;
TLinger = GlobalSock.TLinger;

IPv6 address

pin6_addr = ^in6_addr;
in6_addr = GlobalSock.in6_addr;
Tin6_addr = in6_addr;
TIn6Addr = GlobalSock.TIn6Addr;
PIn6Addr = GlobalSock.PIn6Addr;

Socket address IPv6

psockaddr_in6 = ^sockaddr_in6;
sockaddr_in6 = GlobalSock.sockaddr_in6;
TInetSockAddr6 = sockaddr_in6;
PInetSockAddr6 = psockaddr_in6;

Socket pair

TSockPairArray = array[0..1] of clong;
TSockArray = array[1..2] of clong; Legacy

Socket address

[Expand]

psockaddr_un = ^sockaddr_un;

sockaddr_un = packed record

Address information

PAddrInfo = GlobalSock.PAddrInfo;
TAddrInfo = GlobalSock.TAddrInfo;


Public variables


None defined

Function declarations



Initialization functions

[Expand]
procedure SocketsInit;
Description: To be documented


[Expand]
function SocketsStart:LongWord;
Description: To be documented


[Expand]
function SocketsStop:LongWord;
Description: To be documented


[Expand]
procedure SocketsAsyncStart(Data:Pointer);
Description: To be documented


Sockets functions

[Expand]
function SocketError: cint;
Description: To be documented


[Expand]
function Socket(Domain,SocketType,Protocol:Longint):clong;
Description: To be documented


[Expand]
function Send(Sock:clong; const Buf; BufLen,Flags:Longint):Longint;
Description: To be documented


[Expand]
function SendTo(Sock:clong; const Buf; BufLen,Flags:Longint; var Addr; AddrLen : Longint):Longint;
Description: To be documented


[Expand]
function Recv(Sock:clong; var Buf; BufLen,Flags:Longint):Longint;
Description: To be documented


[Expand]
function RecvFrom(Sock : clong; var Buf; Buflen,Flags : Longint; var Addr; var AddrLen : longint) : longint;
Description: To be documented


[Expand]
function Connect(Sock:clong; const Addr; Addrlen:Longint):Boolean; overload;
Description: To be documented


[Expand]
function Shutdown(Sock:clong; How:Longint):Longint;
Description: To be documented


[Expand]
function Bind(Sock:clong; const Addr; AddrLen:Longint):Boolean;
Description: To be documented


[Expand]
function Listen(Sock:clong; MaxConnect:Longint):Boolean;
Description: To be documented


[Expand]
function Accept(Sock:clong; var Addr; var Addrlen:Longint):clong; overload;
Description: To be documented


[Expand]
function GetSocketName(Sock:clong; var Addr; var Addrlen:Longint):Longint;
Description: To be documented


[Expand]
function GetPeerName(Sock:clong; var Addr; var Addrlen:Longint):Longint;
Description: To be documented


[Expand]
function GetSocketOptions(Sock:clong; Level,OptName:Longint; var OptVal; var optlen:longint):Longint;
Description: To be documented


[Expand]
function SetSocketOptions(Sock:clong; Level,OptName:Longint; const OptVal; optlen:longint):Longint;
Description: To be documented


[Expand]
function SocketPair(Domain,SocketType,Protocol:Longint; var Pair:TSockArray):Longint;
Description: To be documented


[Expand]
function CloseSocket(Sock:clong):Longint;
Description: To be documented


[Expand]
function Inet_Addr(cp: PChar): Longint;
Description: To be documented


[Expand]
function Inet_Ntoa(inaddr: TInAddr): PChar;
Description: To be documented


[Expand]
function Inet_Aton(cp: PChar; inaddr: PInAddr): Longint;
Description: To be documented


[Expand]
function Inet_Pton(family: Longint; Source: PChar; Dest: Pointer): Longint;
Description: To be documented


[Expand]
function Inet_Ntop(family: Longint; Source: Pointer; Dest: PChar; Size: Longint): PChar;
Description: To be documented


[Expand]
function GetHostByAddr(addr: Pointer; len, family: Longint): PHostEnt;
Description: To be documented


[Expand]
function GetHostByName(name: PChar): PHostEnt;
Description: To be documented


[Expand]
function GetHostName(name: PChar; len: Longint): Longint;
Description: To be documented


[Expand]
function GetNetByAddr(addr: Pointer; len, Struct: Integer): PNetEnt;
Description: To be documented


[Expand]
function GetNetByName(name: PChar): PNetEnt;
Description: To be documented


[Expand]
function GetServByPort(port: Longint; proto: PChar): PServEnt;
Description: To be documented


[Expand]
function GetServByName(name, proto: PChar): PServEnt;
Description: To be documented


[Expand]
function GetProtoByNumber(proto: Longint): PProtoEnt;
Description: To be documented


[Expand]
function GetProtoByName(name: PChar): PProtoEnt;
Description: To be documented


[Expand]
function GetAddrInfo(HostName, ServName: PChar; Hints: PAddrInfo; var Addr: PAddrInfo): Longint;
Description: RFC 3493 protocol-independent translation from a host name to an address


[Expand]
procedure FreeAddrInfo(ai: PAddrInfo);
Description: Free address information that GetAddrInfo dynamically allocates in TAddrInfo structures


[Expand]
function GetNameInfo(sa: PSockAddr; salen: Longint; host: PChar; hostlen: DWORD; serv: PChar; servlen: DWORD; flags: Longint): Longint;
Description: RFC 3493 protocol-independent name resolution from an address to a host name and a port number to a service name


[Expand]
function Gai_StrError(ecode: Longint): PChar;
Description: Return an error message for an error code returned by GetAddrInfo or GetNameInfo


RTL sockets functions

[Expand]
function fpsocket(domain:cint; xtype:cint; protocol: cint):clong;
Description: To be documented


[Expand]
function fpsend(s:clong; msg:pointer; len:size_t; flags:cint):ssize_t;
Description: To be documented


[Expand]
function fpsendto(s:clong; msg:pointer; len:size_t; flags:cint; tox :psockaddr; tolen: tsocklen):ssize_t;
Description: To be documented


[Expand]
function fprecv(s:clong; buf: pointer; len: size_t; flags: cint):ssize_t;
Description: To be documented


[Expand]
function fprecvfrom(s:clong; buf: pointer; len: size_t; flags: cint; from : psockaddr; fromlen : psocklen):ssize_t;
Description: To be documented


[Expand]
function fpconnect(s:clong; name  : psockaddr; namelen : tsocklen):cint;
Description: To be documented


[Expand]
function fpshutdown(s:clong; how:cint):cint;
Description: To be documented


[Expand]
function fpbind(s:clong; addrx : psockaddr; addrlen : tsocklen):cint;
Description: To be documented


[Expand]
function fplisten(s:clong; backlog : cint):cint;
Description: To be documented


[Expand]
function fpaccept(s:clong; addrx : psockaddr; addrlen : psocklen):clong;
Description: To be documented


[Expand]
function fpgetsockname(s:clong; name  : psockaddr; namelen : psocklen):cint;
Description: To be documented


[Expand]
function fpgetpeername(s:clong; name  : psockaddr; namelen : psocklen):cint;
Description: To be documented


[Expand]
function fpgetsockopt(s:clong; level:cint; optname:cint; optval:pointer; optlen : psocklen):cint;
Description: To be documented


[Expand]
function fpsetsockopt(s:clong; level:cint; optname:cint; optval:pointer; optlen :tsocklen):cint;
Description: To be documented


[Expand]
function fpsocketpair(d:cint; xtype:cint; protocol:cint; sv:pclong):cint;
Description: To be documented


RTL select functions

[Expand]
function fpselect(n:cint; readfds, writefds, exceptfds: PFDSet; TimeOut: PTimeVal):cint;
Description: To be documented


[Expand]
function fpFD_SET(fdno:clong; var nset: TFDSet):cint;
Description: To be documented


[Expand]
function fpFD_CLR(fdno:clong; var nset: TFDSet):cint;
Description: To be documented


[Expand]
function fpFD_ZERO(out nset: TFDSet):cint;
Description: To be documented


[Expand]
function fpFD_ISSET(fdno:clong; const nset: TFDSet): cint;
Description: To be documented


RTL file/text sockets functions

[Expand]
function fpRead(Handle:LongInt; var BufPtr; Size:DWORD):DWORD;
Description: To be documented


[Expand]
function fpWrite(Handle:LongInt; var BufPtr; Size:DWORD):DWORD;
Description: To be documented


[Expand]
procedure OpenSock(var F:Text);
Description: To be documented


[Expand]
procedure IOSock(var F:Text);
Description: To be documented


[Expand]
procedure FlushSock(var F:Text);
Description: To be documented


[Expand]
procedure CloseSock(var F:text);
Description: To be documented


[Expand]
procedure Sock2Text(Sock:clong; Var SockIn,SockOut:Text); deprecated;
Description: Set up two Pascal Text file descriptors for reading and writing


[Expand]
function Accept(Sock:clong; var addr:TInetSockAddr; var SockIn,SockOut:File):Boolean; deprecated; overload;
Description: To be documented


[Expand]
function Accept(Sock:clong; var addr:TInetSockAddr; var SockIn,SockOut:text):Boolean; deprecated; overload;
Description: To be documented


[Expand]
function Connect(Sock:clong; const addr:TInetSockAddr; var SockIn,SockOut:text):Boolean; deprecated; overload;
Description: To be documented


[Expand]
function Connect(Sock:clong; const addr:TInetSockAddr; var SockIn,SockOut:file):Boolean; deprecated; overload;
Description: To be documented


[Expand]
procedure Sock2File(Sock:clong; Var SockIn,SockOut:File); deprecated;
Description: To be documented


Sockets helper functions

[Expand]
procedure SocketsProcessConfig(Data:Pointer);
Description: To be documented


[Expand]
procedure SocketsProcessFilter(Data:Pointer);
Description: To be documented


[Expand]
procedure SocketsProcessProtocol(Data:Pointer);
Description: To be documented


[Expand]
procedure SocketsProcessSocket(Data:Pointer);
Description: To be documented


[Expand]
procedure SocketsProcessAuth(Data:Pointer);
Description: To be documented


[Expand]
procedure SocketsProcessMonitor(Data:Pointer);
Description: To be documented


[Expand]
procedure SocketsProcessTransport(Data:Pointer);
Description: To be documented


[Expand]
procedure SocketsProcessAdapter(Data:Pointer);
Description: To be documented


[Expand]
procedure SocketsNetworkDeviceAdd(Event:PSocketsDeviceEvent);
Description: To be documented


[Expand]
function SocketsNetworkDeviceRemove(Network:PNetworkDevice):LongWord;
Description: To be documented


[Expand]
function SocketsNetworkDeviceUp(Network:PNetworkDevice):LongWord;
Description: To be documented


[Expand]
function SocketsNetworkDeviceDown(Network:PNetworkDevice):LongWord;
Description: To be documented


[Expand]
function SocketsNetworkDeviceEnum(Network:PNetworkDevice; Data:Pointer):LongWord;
Description: To be documented


[Expand]
function SocketsNetworkDeviceNotify(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;
Description: To be documented


RTL sockets helper functions

[Expand]
function htonl(host:cardinal):cardinal; inline;
Description: To be documented


[Expand]
function ntohl(net:cardinal):cardinal; inline;
Description: To be documented


[Expand]
function htons(host:word):word; inline;
Description: To be documented


[Expand]
function ntohs(net:word):word; inline;
Description: To be documented


[Expand]
function NetAddrToStr(Entry:in_addr):AnsiString;
Description: To be documented


[Expand]
function HostAddrToStr(Entry:in_addr):AnsiString;
Description: To be documented


[Expand]
function StrToHostAddr(IP:AnsiString):in_addr;
Description: To be documented


[Expand]
function StrToNetAddr(IP:AnsiString):in_addr;
Description: To be documented


[Expand]
function HostToNet(Host:in_addr):in_addr;
Description: To be documented


[Expand]
function NetToHost(Net:in_addr):in_addr;
Description: To be documented


[Expand]
function HostToNet(Host:Longint):Longint;
Description: To be documented


[Expand]
function NetToHost(Net:Longint):Longint;
Description: To be documented


[Expand]
function ShortHostToNet(Host:Word):Word;
Description: To be documented


[Expand]
function ShortNetToHost(Net:Word):Word;
Description: To be documented


[Expand]
function HostAddrToStr6(Entry:Tin6_addr):AnsiString;
Description: To be documented


[Expand]
function StrToHostAddr6(IP:String):Tin6_addr; 
Description: To be documented


[Expand]
function NetAddrToStr6(Entry:Tin6_addr):AnsiString;
Description: To be documented


[Expand]
function StrToNetAddr6(IP:AnsiString):TIn6_Addr;
Description: To be documented


Return to Unit Reference