1
<?xml version="1.0" encoding="ISO8859-1"?>
5
$Id: sockets.xml,v 1.3 2005/04/30 22:08:57 michael Exp $
6
This file is part of the FPC documentation.
7
Copyright (C) 1997, by Michael Van Canneyt
9
The FPC documentation is free text; you can redistribute it and/or
10
modify it under the terms of the GNU Library General Public License as
11
published by the Free Software Foundation; either version 2 of the
12
License, or (at your option) any later version.
14
The FPC Documentation is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Library General Public License for more details.
19
You should have received a copy of the GNU Library General Public
20
License along with the FPC documentation; see the file COPYING.LIB. If not,
21
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22
Boston, MA 02111-1307, USA.
25
<module name="sockets">
26
<!-- \FPCexampledir{sockex/} -->
27
<short>TCP/IP Sockets functionality unit</short>
29
This document describes the SOCKETS unit for Free Pascal.
30
it was written for linux by Michael Van Canneyt, and ported to Windows
34
<element name="SOCK_STREAM">
35
<short>Type of socket: stream (connection) type socket (TCP)</short>
37
<element name="SOCK_DGRAM">
38
<short>Type of socket: datagram (conn.less) socket (UDP)</short>
40
<element name="SOCK_RAW">
41
<short>Type of socket: raw socket</short>
43
<element name="SOCK_RDM">
44
<short>Type of socket: reliably-delivered message</short>
46
<element name="SOCK_SEQPACKET">
47
<short>Type of socket: sequential packet socket</short>
49
<element name="SOCK_PACKET">
50
<short>Type of socket: Packet</short>
53
<element name="AF_UNSPEC">
54
<short>Socket domain: Not specified</short>
56
<element name="AF_UNIX">
57
<short>Socket domain: Unix domain sockets</short>
59
<element name="AF_INET">
60
<short>Socket domain: Internet IP Protocol</short>
62
<element name="AF_AX25">
63
<short>Socket domain: Amateur Radio AX.25</short>
65
<element name="AF_IPX">
66
<short>Socket domain: Novell IPX</short>
68
<element name="AF_APPLETALK">
69
<short>Socket domain: Appletalk DDP</short>
71
<element name="AF_NETROM">
72
<short>Socket domain: Amateur radio NetROM</short>
74
<element name="AF_BRIDGE">
75
<short>Socket domain: Multiprotocol bridge</short>
77
<element name="AF_AAL5">
78
<short>Socket domain: Reserved for Werner's ATM</short>
80
<element name="AF_X25">
81
<short>Socket domain: Reserved for X.25 project</short>
83
<element name="AF_INET6">
84
<short>Socket domain: IP version 6</short>
86
<element name="AF_MAX">
87
<short>Socket domain: Maximum value</short>
89
<element name="PF_UNSPEC">
90
<short>Protocol family: Unspecified </short>
92
<element name="PF_INET">
93
<short>Protocol family: Internet IP Protocol</short>
95
<element name="PF_AX25">
96
<short>Protocol family: Amateur Radio AX.25</short>
98
<element name="PF_IPX">
99
<short>Protocol family: Novell IPX</short>
101
<element name="PF_APPLETALK">
102
<short>Protocol family: Appletalk DDP</short>
104
<element name="PF_UNIX">
105
<short>Protocol family: Unix domain sockets</short>
107
<element name="PF_NETROM">
108
<short>Protocol family:Amateur radio NetROM </short>
110
<element name="PF_BRIDGE">
111
<short>Protocol family: Multiprotocol bridge</short>
113
<element name="PF_AAL5">
114
<short>Protocol family: Reserved for Werner's ATM</short>
116
<element name="PF_X25">
117
<short>Protocol family: Reserved for X.25 project</short>
119
<element name="PF_INET6">
120
<short>Protocol family: IP version 6</short>
122
<element name="PF_MAX">
123
<short>Protocol family: Maximum value</short>
126
<element name="TSockAddr">
127
<short>General socket adress record</short>
129
<var>TUnixSockAddr</var> is used to store a general socket addres for the
130
<link id="Bind"/>, <link id="Recv"/> and <link id="Send"/> calls.
133
<element name="TSockAddr.family">
134
<short>Address family</short>
136
<element name="TSockAddr.data">
137
<short>Addres data</short>
140
<element name="TUnixSockAddr">
141
<short>Unix socket address record.</short>
143
<var>TUnixSockAddr</var> is used to store a UNIX socket addres for the
144
<link id="Bind"/>, <link id="Recv"/> and <link id="Send"/> calls.
148
<element name="TUnixSockAddr.family">
149
<short>Address family</short>
151
<element name="TUnixSockAddr.Path">
152
<short>File name</short>
155
<element name="TInetSockAddr">
156
<short>Internet socket address record</short>
158
<var>TUnixSockAddr</var> is used to store a INET socket addres for the
159
<link id="Bind"/>, <link id="Recv"/> and <link id="Send"/> calls.
163
<element name="TInetSockAddr.family">
164
<short>Address family</short>
166
<element name="TInetSockAddr.port">
167
<short>Port number</short>
169
<element name="TInetSockAddr.addr">
170
<short>IP address</short>
172
<element name="TInetSockAddr.pad">
173
<short>Pad data. Do not use.</short>
176
<element name="TSockArray">
177
<short>Type returned by the <link id="SocketPair"/> call.</short>
180
<element name="AF_IMPLINK">
181
<short>Address family: ?</short>
184
<!-- constant Visibility: default -->
185
<element name="AF_PUP">
186
<short>Address family: ?</short>
189
<!-- constant Visibility: default -->
190
<element name="AF_CHAOS">
191
<short>Address family: ?</short>
194
<!-- constant Visibility: default -->
195
<element name="AF_NS">
196
<short>Address family: ?</short>
199
<!-- constant Visibility: default -->
200
<element name="AF_ISO">
201
<short>Address family: ?</short>
204
<!-- constant Visibility: default -->
205
<element name="AF_OSI">
206
<short>Address family: ?</short>
209
<!-- constant Visibility: default -->
210
<element name="AF_ECMA">
211
<short>Address family: ?</short>
214
<!-- constant Visibility: default -->
215
<element name="AF_DATAKIT">
216
<short>Address family: ?</short>
219
<!-- constant Visibility: default -->
220
<element name="AF_CCITT">
221
<short>Address family: ?</short>
224
<!-- constant Visibility: default -->
225
<element name="AF_SNA">
226
<short>Addresss family: Linux SNA project</short>
229
<!-- constant Visibility: default -->
230
<element name="AF_DECnet">
231
<short>Address family: Reserved for DECnet project.</short>
234
<!-- constant Visibility: default -->
235
<element name="AF_DLI">
236
<short>Address family: ?</short>
239
<!-- constant Visibility: default -->
240
<element name="AF_LAT">
241
<short>Address family: ?</short>
244
<!-- constant Visibility: default -->
245
<element name="AF_HYLINK">
246
<short>Address family: ?</short>
249
<!-- constant Visibility: default -->
250
<element name="AF_ROUTE">
251
<short>Address family: Alias to emulate 4.4BSD.</short>
254
<!-- constant Visibility: default -->
255
<element name="AF_LINK">
256
<short>Address family: ?</short>
259
<!-- constant Visibility: default -->
260
<element name="pseudo_AF_XTP">
261
<short>Address family: ?</short>
264
<!-- constant Visibility: default -->
265
<element name="AF_COIP">
266
<short>Address family: ?</short>
269
<!-- constant Visibility: default -->
270
<element name="AF_CNT">
271
<short>Address family: ?</short>
274
<!-- constant Visibility: default -->
275
<element name="pseudo_AF_RTIP">
276
<short>Address family: ?</short>
279
<!-- constant Visibility: default -->
280
<element name="AF_SIP">
281
<short>Address family: ?</short>
284
<!-- constant Visibility: default -->
285
<element name="pseudo_AF_PIP">
286
<short>Address family: ?</short>
289
<!-- constant Visibility: default -->
290
<element name="AF_ISDN">
291
<short>Address family: ?</short>
294
<!-- constant Visibility: default -->
295
<element name="AF_E164">
296
<short>Address family: ?</short>
299
<!-- constant Visibility: default -->
300
<element name="pseudo_AF_KEY">
301
<short>Address family: key management API.</short>
304
<!-- constant Visibility: default -->
305
<element name="AF_NATM">
306
<short>Address family: ?</short>
309
<!-- constant Visibility: default -->
310
<element name="AF_ATM">
311
<short>Address family: ?</short>
314
<!-- constant Visibility: default -->
315
<element name="pseudo_AF_HDRCMPLT">
316
<short>Address family: ?</short>
319
<!-- constant Visibility: default -->
320
<element name="AF_NETGRAPH">
321
<short>Address family: ?</short>
324
<!-- constant Visibility: default -->
325
<element name="SOCK_MAXADDRLEN">
326
<short>Maximum socket address length for <link id="Bind"/> call.</short>
333
<!-- constant Visibility: default -->
334
<element name="PF_IMPLINK">
335
<short>Protocol Family: ?</short>
338
<!-- constant Visibility: default -->
339
<element name="PF_PUP">
340
<short>Protocol Family: ?</short>
343
<!-- constant Visibility: default -->
344
<element name="PF_CHAOS">
345
<short>Protocol Family: ?</short>
348
<!-- constant Visibility: default -->
349
<element name="PF_NS">
350
<short>Protocol Family: ?</short>
353
<!-- constant Visibility: default -->
354
<element name="PF_ISO">
355
<short>Protocol Family: ?</short>
358
<!-- constant Visibility: default -->
359
<element name="PF_OSI">
360
<short>Protocol Family: ?</short>
363
<!-- constant Visibility: default -->
364
<element name="PF_ECMA">
365
<short>Protocol Family: ?</short>
368
<!-- constant Visibility: default -->
369
<element name="PF_DATAKIT">
370
<short>Protocol Family: ?</short>
373
<!-- constant Visibility: default -->
374
<element name="PF_CCITT">
375
<short>Protocol Family: ?</short>
378
<!-- constant Visibility: default -->
379
<element name="PF_SNA">
380
<short>Protocol Family: Linux SNA project</short>
383
<!-- constant Visibility: default -->
384
<element name="PF_DECnet">
385
<short>Protocol Family: DECNET project</short>
388
<!-- constant Visibility: default -->
389
<element name="PF_DLI">
390
<short>Protocol Family: ?</short>
393
<!-- constant Visibility: default -->
394
<element name="PF_LAT">
395
<short>Protocol Family: ?</short>
398
<!-- constant Visibility: default -->
399
<element name="PF_HYLINK">
400
<short>Protocol Family: ?</short>
403
<!-- constant Visibility: default -->
404
<element name="PF_ROUTE">
405
<short>Protocol Family: ?</short>
408
<!-- constant Visibility: default -->
409
<element name="PF_LINK">
410
<short>Protocol Family: ?</short>
413
<!-- constant Visibility: default -->
414
<element name="PF_XTP">
415
<short>Protocol Family: ?</short>
418
<!-- constant Visibility: default -->
419
<element name="PF_COIP">
420
<short>Protocol Family: ?</short>
423
<!-- constant Visibility: default -->
424
<element name="PF_CNT">
425
<short>Protocol Family: ?</short>
428
<!-- constant Visibility: default -->
429
<element name="PF_SIP">
430
<short>Protocol Family: ?</short>
433
<!-- constant Visibility: default -->
434
<element name="PF_RTIP">
435
<short>Protocol Family: ?</short>
438
<!-- constant Visibility: default -->
439
<element name="PF_PIP">
440
<short>Protocol Family: ?</short>
443
<!-- constant Visibility: default -->
444
<element name="PF_ISDN">
445
<short>Protocol Family: ?</short>
448
<!-- constant Visibility: default -->
449
<element name="PF_KEY">
450
<short>Protocol family: Key management API</short>
453
<!-- constant Visibility: default -->
454
<element name="PF_NATM">
455
<short>Protocol Family: ?</short>
458
<!-- constant Visibility: default -->
459
<element name="PF_ATM">
460
<short>Protocol Family: ?</short>
463
<!-- constant Visibility: default -->
464
<element name="PF_NETGRAPH">
465
<short>Protocol Family: ?</short>
468
<!-- constant Visibility: default -->
469
<element name="SOL_SOCKET">
470
<short>Socket option level: Socket level</short>
473
<!-- constant Visibility: default -->
474
<element name="SO_DEBUG">
475
<short>Socket option level: debug</short>
478
<!-- constant Visibility: default -->
479
<element name="SO_REUSEADDR">
480
<short>Socket option: Reuse address</short>
483
<!-- constant Visibility: default -->
484
<element name="SO_TYPE">
485
<short>Socket option: Type</short>
488
<!-- constant Visibility: default -->
489
<element name="SO_ERROR">
490
<short>Socket option: Error</short>
493
<!-- constant Visibility: default -->
494
<element name="SO_DONTROUTE">
495
<short>Socket option: Don't route</short>
498
<!-- constant Visibility: default -->
499
<element name="SO_BROADCAST">
500
<short>Socket option: Broadcast</short>
503
<!-- constant Visibility: default -->
504
<element name="SO_SNDBUF">
505
<short>Socket option: Send buffer</short>
508
<!-- constant Visibility: default -->
509
<element name="SO_RCVBUF">
510
<short>Socket option: receive buffer</short>
513
<!-- constant Visibility: default -->
514
<element name="SO_KEEPALIVE">
515
<short>Socket option: keep alive</short>
518
<!-- constant Visibility: default -->
519
<element name="SO_OOBINLINE">
520
<short>Socket option: ?</short>
523
<!-- constant Visibility: default -->
524
<element name="SO_NO_CHECK">
525
<short>Socket option: ?</short>
528
<!-- constant Visibility: default -->
529
<element name="SO_PRIORITY">
530
<short>Socket option: ?</short>
533
<!-- constant Visibility: default -->
534
<element name="SO_LINGER">
535
<short>Socket option: ?</short>
538
<!-- constant Visibility: default -->
539
<element name="SO_BSDCOMPAT">
540
<short>Socket option: ?</short>
543
<!-- constant Visibility: default -->
544
<element name="SO_PASSCRED">
545
<short>Socket option: ?</short>
548
<!-- constant Visibility: default -->
549
<element name="SO_PEERCRED">
550
<short>Socket option: ?</short>
553
<!-- constant Visibility: default -->
554
<element name="SO_RCVLOWAT">
555
<short>Socket option: ?</short>
558
<!-- constant Visibility: default -->
559
<element name="SO_SNDLOWAT">
560
<short>Socket option: ?</short>
563
<!-- constant Visibility: default -->
564
<element name="SO_RCVTIMEO">
565
<short>Socket option: ?</short>
568
<!-- constant Visibility: default -->
569
<element name="SO_SNDTIMEO">
570
<short>Socket option: ?</short>
573
<!-- constant Visibility: default -->
574
<element name="SO_SECURITY_AUTHENTICATION">
575
<short>Socket option: ?</short>
578
<!-- constant Visibility: default -->
579
<element name="SO_SECURITY_ENCRYPTION_TRANSPORT">
580
<short>Socket option: ?</short>
583
<!-- constant Visibility: default -->
584
<element name="SO_SECURITY_ENCRYPTION_NETWORK">
585
<short>Socket option: ?</short>
588
<!-- constant Visibility: default -->
589
<element name="SO_BINDTODEVICE">
590
<short>Socket option: ?</short>
593
<!-- constant Visibility: default -->
594
<element name="SO_ATTACH_FILTER">
595
<short>Socket option: ?</short>
598
<!-- constant Visibility: default -->
599
<element name="SO_DETACH_FILTER">
600
<short>Socket option: ?</short>
603
<!-- constant Visibility: default -->
604
<element name="SO_PEERNAME">
605
<short>Socket option: ?</short>
608
<!-- constant Visibility: default -->
609
<element name="SO_TIMESTAMP">
610
<short>Socket option: ?</short>
613
<!-- constant Visibility: default -->
614
<element name="SCM_TIMESTAMP">
615
<short>Socket option: ?</short>
618
<!-- constant Visibility: default -->
619
<element name="SO_ACCEPTCONN">
620
<short>Socket option: ?</short>
623
<!-- constant Visibility: default -->
624
<element name="SHUT_RD">
625
<short>Shutdown read part of full duplex socket</short>
628
<!-- constant Visibility: default -->
629
<element name="SHUT_WR">
630
<short>Shutdown write part of full duplex socket</short>
633
<!-- constant Visibility: default -->
634
<element name="SHUT_RDWR">
635
<short>Shutdown read and write part of full duplex socket</short>
638
<!-- alias type Visibility: default -->
639
<element name="sa_family_t">
640
<short>Address family type</short>
643
<!-- constant Visibility: default -->
644
<element name="PF_LOCAL">
645
<short>Protocol family: Unix socket</short>
648
<!-- constant Visibility: default -->
649
<element name="PF_FILE">
650
<short>Protocol family: Unix socket (alias)</short>
653
<!-- constant Visibility: default -->
654
<element name="AF_LOCAL">
655
<short>Address family: Unix socket</short>
658
<!-- constant Visibility: default -->
659
<element name="AF_FILE">
660
<short>Address family: Unix socket (alias)</short>
663
<!-- constant Visibility: default -->
664
<element name="MSG_OOB">
665
<short>Receive flags: receive out-of-band data.</short>
668
<!-- constant Visibility: default -->
669
<element name="MSG_PEEK">
670
<short>Receive flags: peek at data, don't remove from buffer.</short>
673
<!-- constant Visibility: default -->
674
<element name="MSG_DONTROUTE">
675
<short>Send flags: don't use gateway</short>
678
<!-- constant Visibility: default -->
679
<element name="MSG_TRYHARD">
680
<short>Receive flags: ?</short>
683
<!-- constant Visibility: default -->
684
<element name="MSG_CTRUNC">
685
<short>Receive flags: Control Data was discarded (buffer too small)</short>
688
<!-- constant Visibility: default -->
689
<element name="MSG_PROXY">
690
<short>Receive flags: ?</short>
693
<!-- constant Visibility: default -->
694
<element name="MSG_TRUNC">
695
<short>Receive flags: packet Data was discarded (buffer too small)</short>
698
<!-- constant Visibility: default -->
699
<element name="MSG_DONTWAIT">
700
<short>Receive flags: Non-blocking operation request.</short>
703
<!-- constant Visibility: default -->
704
<element name="MSG_EOR">
705
<short>Receive flags: End of record</short>
708
<!-- constant Visibility: default -->
709
<element name="MSG_WAITALL">
710
<short>Receive flags: Wait till operation completed.</short>
713
<!-- constant Visibility: default -->
714
<element name="MSG_FIN">
715
<short>Receive flags: ?</short>
718
<!-- constant Visibility: default -->
719
<element name="MSG_SYN">
720
<short>Receive flags: ?</short>
723
<!-- constant Visibility: default -->
724
<element name="MSG_CONFIRM">
725
<short>Send flags: Conform connection</short>
728
<!-- constant Visibility: default -->
729
<element name="MSG_RST">
730
<short>Receive flags: ?</short>
733
<!-- constant Visibility: default -->
734
<element name="MSG_ERRQUERE">
735
<short>Receive flags: ?</short>
738
<!-- constant Visibility: default -->
739
<element name="MSG_NOSIGNAL">
740
<short>Receive flags: Suppress SIG_PIPE signal.</short>
743
<!-- constant Visibility: default -->
744
<element name="MSG_MORE">
745
<short>Receive flags: ?</short>
748
<!-- constant Visibility: default -->
749
<element name="S_IN">
750
<short>Input socket in socket pair.</short>
753
<!-- constant Visibility: default -->
754
<element name="S_OUT">
755
<short>Output socket in socket pair</short>
758
<!-- record type Visibility: default -->
759
<element name="in_addr">
760
<short>General inet socket address.</short>
763
<!-- variable Visibility: default -->
764
<element name="in_addr.s_addr">
765
<short>Actual address</short>
768
<!-- variable Visibility: default -->
769
<element name="TSockAddr.sa_family">
770
<short>General socket address: Address family</short>
773
<!-- variable Visibility: default -->
774
<element name="TSockAddr.sa_data">
775
<short>General socket address: Address data</short>
778
<!-- pointer type Visibility: default -->
779
<element name="pSockAddr">
780
<short>Pointer to <link id="TSockAddr"/></short>
783
<!-- pointer type Visibility: default -->
784
<element name="pInetSockAddr">
785
<short>Pointer to <link id="TInetSockAddr"/></short>
788
<!-- record type Visibility: default -->
789
<element name="Tin6_addr">
790
<short>Alias for <link id="TInetSockAddr6"/></short>
793
<!-- pointer type Visibility: default -->
794
<element name="pIn6_Addr">
795
<short>Pointer to <link id="Tin6_addr"/></short>
798
<!-- record type Visibility: default -->
799
<element name="TInetSockAddr6">
800
<short>Record for IPV6 socket address.</short>
803
<!-- variable Visibility: default -->
804
<element name="TInetSockAddr6.sin6_family">
805
<short>Address family</short>
808
<!-- variable Visibility: default -->
809
<element name="TInetSockAddr6.sin6_port">
813
<!-- variable Visibility: default -->
814
<element name="TInetSockAddr6.sin6_flowinfo">
815
<short>Flow information.</short>
818
<!-- variable Visibility: default -->
819
<element name="TInetSockAddr6.sin6_addr">
820
<short>IPV6 address</short>
823
<!-- variable Visibility: default -->
824
<element name="TInetSockAddr6.sin6_scope_id">
828
<!-- alias type Visibility: default -->
829
<element name="sockaddr_in6">
830
<short>Alias for <link id="TInetSockAddr6"/></short>
833
<!-- pointer type Visibility: default -->
834
<element name="psockaddr_in6">
835
<short>Pointer to <link id="sockaddr_in6"/></short>
838
<!-- array type Visibility: default -->
839
<element name="TSockPairArray">
840
<short>Array of sockets, used in <link id="SocketPair"/> call.</short>
843
<!-- variable Visibility: default -->
844
<element name="SocketError">
845
<short>Contains the error code for the last socket operation.</short>
847
<var>SocketError</var> contains the error code for the last socket
848
operation. It can be examined to return the last socket error.
852
<!-- function Visibility: default -->
853
<element name="fpsocket">
854
<short>Alias for the <link id="socket"/> call</short>
857
<!-- function Visibility: default -->
858
<element name="fprecv">
859
<short>Alias for the <link id="recv"/> call</short>
862
<!-- function Visibility: default -->
863
<element name="fprecvfrom">
864
<short>Alias for the <link id="recvfrom"/> call</short>
867
<!-- function Visibility: default -->
868
<element name="fpsend">
869
<short>Alias for the <link id="send"/> call</short>
872
<!-- function Visibility: default -->
873
<element name="fpsendto">
874
<short>Alias for the <link id="send"/> call</short>
877
<!-- function Visibility: default -->
878
<element name="fpbind">
879
<short>Alias for the <link id="bind"/> call</short>
882
<!-- function Visibility: default -->
883
<element name="fplisten">
884
<short>Alias for the <link id="listen"/> call</short>
887
<!-- function Visibility: default -->
888
<element name="fpaccept">
889
<short>Alias for the <link id="accept"/> call</short>
892
<!-- function Visibility: default -->
893
<element name="fpconnect">
894
<short>Alias for the <link id="connect"/> call</short>
897
<!-- function Visibility: default -->
898
<element name="fpshutdown">
899
<short>Alias for the <link id="shutdown"/> call</short>
902
<!-- function Visibility: default -->
903
<element name="fpgetsockname">
904
<short>Alias for the <link id="GetSocketName"/> call</short>
907
<!-- function Visibility: default -->
908
<element name="fpgetpeername">
909
<short>Alias for the <link id="GetPeerName"/> call</short>
912
<!-- function Visibility: default -->
913
<element name="fpgetsockopt">
914
<short>Alias for the <link id="GetSocketOptions"/> call</short>
917
<!-- function Visibility: default -->
918
<element name="fpsetsockopt">
919
<short>Alias for the <link id="SetSocketOptions"/> call</short>
922
<!-- function Visibility: default -->
923
<element name="fpsocketpair">
924
<short>Alias for the <link id="SocketPair"/> call</short>
927
<!-- function Visibility: default -->
928
<element name="CloseSocket">
929
<short>Closes a socket handle.</short>
931
<var>CloseSocket</var> closes a socket handle. It returns 0 if the socket
932
was closed succesfully, -1 if it failed.
935
On error, -1 is returned.
942
<!-- function Visibility: default -->
943
<element name="SendTo">
944
<short>Send data through an unconnected socket to an address.</short>
946
<var>SendTo</var> sends data from buffer <var>Buf</var> with length
947
<var>Buflen</var> through socket <var>Sock</var> with options
948
<var>Flags</var>. The data is sent to address <var>Addr</var>, which has
949
length <var>AddrLen</var>
952
On error, -1 is returned.
957
<link id="RecvFrom"/>
961
<!-- function Visibility: default -->
962
<element name="RecvFrom">
963
<short>Receive data from an unconnected socket</short>
965
<var>RecvFrom</var> receives data in buffer <var>Buf</var> with maximum
966
length <var>BufLen</var> from socket <var>Sock</var>.
967
Receipt is controlled by options in <var>Flags</var>. <var>Addr</var> will
968
be filled with the address from the sender, and will have length
969
The function returns the number of bytes received, or -1 on error.
973
On error, -1 is returned.
978
<link id="RecvFrom"/>
982
<element name="Accept">
983
<short>Accept a connection from a socket.</short>
986
<var>FPAccept</var> accepts a connection from a socket <var>Sock</var>, which was
987
listening for a connection. If a connection is accepted, a file descriptor
988
is returned. On error <var>-1</var> is returned. The returned socket may NOT
989
be used to accept more connections. The original socket remains open.
992
The <var>Accept</var> call fills the address of the connecting entity in
993
<var>Addr</var>, and sets its length in <var>Addrlen</var>. <var>Addr</var> should
994
be pointing to enough space, and <var>Addrlen</var> should be set to the
995
amount of space available, prior to the call.
998
The alternate forms of the <link id="Accept"/> command, with the
999
<var>Text</var> or <var>File</var> parameters are equivalent
1000
to subsequently calling the regular <link id="Accept"/> function and the
1001
<link id="Sock2Text"/> or <link id="Sock2File"/> functions.
1002
These functions return <var>True</var> if successful, <var>False</var> otherwise.
1007
On error, <var>-1</var> is returned, and errors are reported in
1008
<var>SocketError</var>, and include the following:
1011
<dt>SYS_EBADF</dt><dd>The socket descriptor is invalid.</dd>
1012
<dt>SYS_ENOTSOCK</dt><dd>The descriptor is not a socket.</dd>
1013
<dt>SYS_EOPNOTSUPP</dt><dd>The socket type doesn't support the <var>Listen</var> operation.</dd>
1014
<dt>SYS_EFAULT</dt><dd><var>Addr</var> points outside your address space.</dd>
1015
<dt>SYS_EWOULDBLOCK</dt><dd>The requested operation would block the process.</dd>
1020
<link id="Connect"/>
1023
<example file="sockex/socksvr"/>
1026
<element name="Bind">
1027
<short>Bind a socket to an address.</short>
1030
<var>Bind</var> binds the socket <var>Sock</var> to address <var>Addr</var>. <var>Addr</var>
1031
has length <var>Addrlen</var>.
1032
The function returns <var>True</var> if the call was succesful, <var>False</var> if
1036
The form of the <var>Bind</var> command with the <link id="TUnixSockAddr"/>
1037
is equivalent to subsequently calling <link id="Str2UnixSockAddr"/> and the
1038
regular <var>Bind</var> function.
1039
The function returns <var>True</var> if successfull, <var>False</var> otherwise.
1044
Errors are returned in <var>SocketError</var> and include the following:
1047
<dt>SYS_EBADF</dt><dd> The socket descriptor is invalid.</dd>
1048
<dt>SYS_EINVAL</dt><dd> The socket is already bound to an address,</dd>
1049
<dt>SYS_EACCESS</dt><dd> Address is protected and you don't have permission to open it.</dd>
1052
More arrors can be found in the Unix man pages.
1060
<element name="Connect">
1061
<short>Open a connection to a server socket.</short>
1064
<var>Connect</var> opens a connection to a peer, whose address is described by
1065
<var>Addr</var>. <var>AddrLen</var> contains the length of the address.
1066
The type of <var>Addr</var> depends on the kind of connection you're trying to
1067
make, but is generally one of <var>TSockAddr</var> or <var>TUnixSockAddr</var>.
1070
The forms of the <link id="Connect"/> command with the <var>Text</var> or
1071
<var>File</var> arguments are equivalent to subsequently calling the regular <var>Connect</var>
1072
function and the <link id="Sock2Text"/> or <link id="Sock2File"/> functions.
1073
These functions return <var>True</var> if successfull, <var>False</var> otherwise.
1076
The <var>Connect</var> function returns a file descriptor if the call
1077
was successfull, <var>-1</var> in case of error.
1081
On error, <var>-1</var> is returned and errors are reported in
1082
<var>SocketError</var>.
1089
<example file="sockex/sockcli"/>
1090
<example file="sockex/pfinger"/>
1093
<element name="GetPeerName">
1094
<short>Return the name (address) of the connected peer.</short>
1097
<var>GetPeerName</var> returns the name of the entity connected to the
1098
specified socket <var>Sock</var>. The Socket must be connected for this call to
1102
<var>Addr</var> should point to enough space to store the name, the
1103
amount of space pointed to should be set in <var>Addrlen</var>.
1104
When the function returns succesfully, <var>Addr</var> will be filled with the
1105
name, and <var>Addrlen</var> will be set to the length of <var>Addr</var>.
1110
Errors are reported in <var>SocketError</var>, and include the following:
1113
<dt>SYS_EBADF</dt><dd> The socket descriptor is invalid.</dd>
1114
<dt>SYS_ENOBUFS</dt><dd> The system doesn't have enough buffers to perform the operation.</dd>
1115
<dt>SYS_ENOTSOCK</dt><dd> The descriptor is not a socket.</dd>
1116
<dt>SYS_EFAULT</dt><dd> <var>Addr</var> points outside your address space.</dd>
1117
<dt>SYS_ENOTCONN</dt><dd> The socket isn't connected.</dd>
1121
<link id="Connect"/>
1126
<element name="GetSocketName">
1127
<short>Return name of socket.</short>
1129
<var>GetSockName</var> returns the current name of the specified socket
1130
<var>Sock</var>. <var>Addr</var> should point to enough space to store the name, the
1131
amount of space pointed to should be set in <var>Addrlen</var>.
1132
When the function returns succesfully, <var>Addr</var> will be filled with the
1133
name, and <var>Addrlen</var> will be set to the length of <var>Addr</var>.
1137
Errors are reported in <var>SocketError</var>, and include the following:
1140
<dt>SYS_EBADF</dt><dd> The socket descriptor is invalid.</dd>
1141
<dt>SYS_ENOBUFS</dt><dd> The system doesn't have enough buffers to perform the operation.</dd>
1142
<dt>SYS_ENOTSOCK</dt><dd> The descriptor is not a socket.</dd>
1143
<dt>SYS_EFAULT</dt><dd> <var>Addr</var> points outside your address space.</dd>
1151
<element name="GetSocketOptions">
1152
<short>Get current socket options</short>
1155
<var>GetSocketOptions</var> gets the connection options for socket <var>Sock</var>.
1156
The socket may be obtained from different levels, indicated by <var>Level</var>,
1157
which can be one of the following:
1160
<dt>SOL_SOCKET</dt><dd> From the socket itself. </dd>
1161
<dt>XXX</dt><dd> set <var>Level</var> to <var>XXX</var>, the protocol number of the protocol
1162
which should interprete the option. </dd>
1165
For more information on this call, refer to the unix manual page \seem{getsockopt}{2}.
1170
Errors are reported in <var>SocketError</var>, and include the following:
1173
<dt>SYS_EBADF</dt><dd> The socket descriptor is invalid.</dd>
1174
<dt>SYS_ENOTSOCK</dt><dd> The descriptor is not a socket.</dd>
1175
<dt>SYS_EFAULT</dt><dd> <var>OptVal</var> points outside your address space.</dd>
1179
<link id="GetSocketOptions"/>
1183
<element name="Listen">
1184
<short>Listen for connections on socket.</short>
1187
<var>Listen</var> listens for up to <var>MaxConnect</var> connections from socket
1188
<var>Sock</var>. The socket <var>Sock</var> must be of type <var>SOCK_STREAM</var> or
1189
<var>Sock_SEQPACKET</var>.
1192
The function returns <var>True</var> if a connection was accepted, <var>False</var>
1193
if an error occurred.
1198
Errors are reported in <var>SocketError</var>, and include the following:
1201
<dt>SYS_EBADF</dt><dd> The socket descriptor is invalid.</dd>
1202
<dt>SYS_ENOTSOCK</dt><dd> The descriptor is not a socket.</dd>
1203
<dt>SYS_EOPNOTSUPP</dt><dd> The socket type doesn't support the <var>Listen</var> operation.</dd>
1209
<link id="Connect"/>
1213
<element name="Recv">
1214
<short>Receive data on socket</short>
1217
<var>Recv</var> reads at most <var>Addrlen</var> bytes from socket <var>Sock</var> into
1218
address <var>Addr</var>. The socket must be in a connected state.
1219
<var>Flags</var> can be one of the following:
1222
<dt>1</dt><dd>Process out-of band data.</dd>
1223
<dt>4</dt><dd>Bypass routing, use a direct interface.</dd>
1224
<dt>??</dt><dd> Wait for full request or report an error.</dd>
1227
The functions returns the number of bytes actually read from the socket, or
1228
-1 if a detectable error occurred.
1233
Errors are reported in <var>SocketError</var>, and include the following:
1236
<dt>SYS_EBADF</dt><dd> The socket descriptor is invalid.</dd>
1237
<dt>SYS_ENOTCONN</dt><dd> The socket isn't connected.</dd>
1238
<dt>SYS_ENOTSOCK</dt><dd> The descriptor is not a socket.</dd>
1239
<dt>SYS_EFAULT</dt><dd> The address is outside your address space.</dd>
1240
<dt>SYS_EMSGSIZE</dt><dd> The message cannot be sent atomically.</dd>
1241
<dt>SYS_EWOULDBLOCK</dt><dd> The requested operation would block the process.</dd>
1242
<dt>SYS_ENOBUFS</dt><dd> The system doesn't have enough free buffers available.</dd>
1250
<element name="Send">
1251
<short>Send data through socket</short>
1254
<var>Send</var> sends <var>AddrLen</var> bytes starting from address <var>Addr</var>
1255
to socket <var>Sock</var>. <var>Sock</var> must be in a connected state.
1256
The function returns the number of bytes sent, or -1 if a detectable
1260
<var>Flags</var> can be one of the following:
1263
<dt>1</dt><dd>Process out-of band data.</dd>
1264
<dt>4</dt><dd>Bypass routing, use a direct interface.</dd>
1269
Errors are reported in <var>SocketError</var>, and include the following:
1272
<dt>SYS_EBADF</dt><dd> The socket descriptor is invalid.</dd>
1273
<dt>SYS_ENOTSOCK</dt><dd> The descriptor is not a socket.</dd>
1274
<dt>SYS_EFAULT</dt><dd> The address is outside your address space.</dd>
1275
<dt>SYS_EMSGSIZE</dt><dd> The message cannot be sent atomically.</dd>
1276
<dt>SYS_EWOULDBLOCK</dt><dd> The requested operation would block the process.</dd>
1277
<dt>SYS_ENOBUFS</dt><dd> The system doesn't have enough free buffers available.</dd>
1285
<element name="SetSocketOptions">
1286
<short>Set socket options.</short>
1289
<var>SetSocketOptions</var> sets the connection options for socket <var>Sock</var>.
1290
The socket may be manipulated at different levels, indicated by <var>Level</var>,
1291
which can be one of the following:
1294
<dt>SOL_SOCKET</dt><dd> To manipulate the socket itself. </dd>
1295
<dt>XXX</dt><dd> set <var>Level</var> to <var>XXX</var>, the protocol number of the protocol
1296
which should interprete the option. </dd>
1299
For more information on this call, refer to the unix manual page
1300
<file>setsockopt</file>
1305
Errors are reported in <var>SocketError</var>, and include the following:
1308
<dt>SYS_EBADF</dt><dd> The socket descriptor is invalid.</dd>
1309
<dt>SYS_ENOTSOCK</dt><dd> The descriptor is not a socket.</dd>
1310
<dt>SYS_EFAULT</dt><dd> <var>OptVal</var> points outside your address space.</dd>
1314
<link id="GetSocketOptions"/>
1318
<element name="Shutdown">
1319
<short>Close one end of full duplex connection.</short>
1322
<var>ShutDown</var> closes one end of a full duplex socket connection, described
1323
by <var>Sock</var>. The parameter <var>How</var> determines how the connection
1324
will be shut down, and can be one of the following:
1327
<dt>0</dt><dd>Further receives are disallowed.</dd>
1328
<dt>1</dt><dd>Further sends are disallowed.</dd>
1329
<dt>2</dt><dd>Sending nor receiving are allowed.</dd>
1332
On succes, the function returns 0, on error -1 is returned.
1337
<var>SocketError</var> is used to report errors, and includes the following:
1340
<dt>SYS_EBADF</dt><dd> The socket descriptor is invalid.</dd>
1341
<dt>SYS_ENOTCONN</dt><dd> The socket isn't connected.</dd>
1342
<dt>SYS_ENOTSOCK</dt><dd> The descriptor is not a socket.</dd>
1347
<link id="Connect"/>
1351
<element name="Sock2File">
1352
<short>Convert socket to untyped file descriptors</short>
1354
<var>Sock2File</var> transforms a socket <var>Sock</var> into 2 Pascal file
1355
descriptors of type <var>File</var>, one for reading from the socket
1356
(<var>SockIn</var>), one for writing to the socket (<var>SockOut</var>).
1363
<link id="Sock2Text"/>
1367
<element name="Sock2Text">
1368
<short>Convert socket to text file descriptors</short>
1370
<var>Sock2Text</var> transforms a socket <var>Sock</var> into 2 Pascal file
1371
descriptors of type <var>Text</var>, one for reading from the socket
1372
(<var>SockIn</var>), one for writing to the socket (<var>SockOut</var>).
1379
<link id="Sock2File"/>
1383
<element name="Socket">
1384
<short>Create new socket</short>
1387
<var>Socket</var> creates a new socket in domain <var>Domain</var>, from type
1388
<var>SocketType</var> using protocol <var>Protocol</var>.
1389
The Domain, Socket type and Protocol can be specified using predefined
1390
constants (see the section on constants for available constants)
1391
If succesfull, the function returns a socket descriptor, which can be passed
1392
to a subsequent <link id="Bind"/> call. If unsuccesfull, the function returns -1.
1395
for an example, see <link id="Accept"/>.
1400
Errors are returned in <var>SocketError</var>, and include the follwing:
1403
<dt>SYS_EPROTONOSUPPORT</dt><dd> The protocol type or the specified protocol is not
1404
supported within this domain.</dd>
1405
<dt>SYS_EMFILE</dt><dd>The per-process descriptor table is full.</dd>
1406
<dt>SYS_ENFILE</dt><dd>The system file table is full.</dd>
1407
<dt>SYS_EACCESS</dt><dd> Permission to create a socket of the specified type
1408
and/or protocol is denied.</dd>
1409
<dt>SYS_ENOBUFS</dt><dd>Insufficient buffer space is available. The socket
1410
cannot be created until sufficient resources are freed.</dd>
1414
<link id="SocketPair"/>, \seem{socket}{2}
1419
<element name="SocketPair">
1420
<short>Create socket pair</short>
1422
<var>SocketPair</var> creates 2 sockets in domain <var>Domain</var>, from type
1423
<var>SocketType</var> and using protocol <var>Protocol</var>.
1424
The pair is returned in <var>Pair</var>, and they are indistinguishable.
1425
The function returns -1 upon error and 0 upon success.
1428
Errors are reported in <var>SocketError</var>, and are the same as in <link id="Socket"/>
1431
<link id="Str2UnixSockAddr"/>
1435
<element name="Str2UnixSockAddr">
1436
<short>Convert path to <link id="TUnixSockAddr"/></short>
1438
<var>Str2UnixSockAddr</var> transforms a Unix socket address in a string to a
1439
<var>TUnixSockAddr</var> structure which can be passed to the <link id="Bind"/> call.
1450
<element name="htonl">
1451
<short>Convert long integer from host ordered to network ordered</short>
1453
<var>htonl</var> makes sure that the bytes in <var>host</var> are ordered
1454
in the correct way for sending over the network and returns the correctly
1464
<element name="htons">
1465
<short>Convert short integer from host ordered to network ordered</short>
1467
<var>htons</var> makes sure that the bytes in <var>host</var> are ordered
1468
in the correct way for sending over the network and returns the correctly
1478
<element name="ntohl">
1479
<short>Convert long integer from network ordered to host ordered</short>
1481
<var>ntohs</var> makes sure that the bytes in <var>Net</var>, received from
1482
the network, are ordered in the correct way for handling by the host
1483
machinen, and returns the correctly ordered result.
1492
<element name="ntohs">
1493
<short>Convert short integer from network ordered to host ordered</short>
1495
<var>ntohs</var> makes sure that the bytes in <var>Net</var>, received from
1496
the network, are ordered in the correct way for handling by the host
1497
machinen, and returns the correctly ordered result.
1506
<!-- unresolved type reference Visibility: default -->
1507
<element name="UnixType">
1508
<short>Basic Unix types</short>
1515
<!-- alias type Visibility: default -->
1516
<element name="TIn_addr">
1517
<short>Alias for <link id="#rtl.sockets.In_addr">in_addr</link> record type.</short>
1520
<!-- pointer type Visibility: default -->
1521
<element name="pin_addr">
1522
<short>Pointer to <link id="#rtl.sockets.In_addr">in_addr</link> record.</short>
1525
<!-- alias type Visibility: default -->
1526
<element name="TInAddr">
1527
<short>Alias for <link id="#rtl.sockets.In_addr">in_addr</link> record type.</short>
1530
<!-- array type Visibility: default -->
1531
<element name="in_addrbytes">
1532
<short>Array with same length as <link id="#rtl.sockets.In_addr">in_addr</link> record</short>
1534
<var>in_addrbytes</var> is used to typecast a <link id="in_addr"/> record to
1539
<!-- alias type Visibility: default -->
1540
<element name="Sockaddr">
1541
<short>Alias for <link id="#rtl.sockets.TSockAddr">TSockAddr</link> record type.</short>
1544
<!-- function Visibility: default -->
1545
<element name="NetAddrToStr">
1546
<short>Convert a network address to a string.</short>
1548
<var>NetAddrToStr</var> converts the network address in <var>Entry</var> to
1549
a string representation in human-readable form (a dotted quad).
1552
<link id="HostAddrToStr"/>
1553
<link id="StrToNetAddr"/>
1554
<link id="StrToHostAddr"/>
1558
<!-- function Visibility: default -->
1559
<element name="HostAddrToStr">
1560
<short>Convert a host address to a string.</short>
1563
<var>HostAddrToStr</var> converts the host address in <var>Entry</var> to
1564
a string representation in human-readable form (a dotted quad).
1567
Basically, it is the same as <link id="NetAddrToStr"/>, but with the bytes
1572
<link id="NetAddrToStr"/>
1573
<link id="StrToHostAddr"/>
1574
<link id="StrToNetAddr"/>
1578
<!-- function Visibility: default -->
1579
<element name="StrToHostAddr">
1580
<short>Convert a string to a host address.</short>
1582
<var>StrToHostAddr</var> converts the string representation in <var>IP</var>
1583
to a host address and returns the host address.
1586
On error, the host address is filled with zeroes.
1589
<link id="NetAddrToStr"/>
1590
<link id="HostAddrToStr"/>
1591
<link id="StrToNetAddr"/>
1595
<!-- function Visibility: default -->
1596
<element name="StrToNetAddr">
1597
<short>Convert a string to a network address.</short>
1599
<var>StrToNetAddr</var> converts the string representation in <var>IP</var>
1600
to a network address and returns the network address.
1603
On error, the network address is filled with zeroes.
1606
<link id="NetAddrToStr"/>
1607
<link id="HostAddrToStr"/>
1608
<link id="StrToHostAddr"/>
1612
<!-- function Visibility: default -->
1613
<element name="HostToNet">
1614
<short>Convert a host address to a network address</short>
1616
<var>HostToNet</var> converts a host address to a network address.
1617
It takes care of endianness of the host machine. The address can be
1618
specified as a dotted quad or as a longint.
1624
<link id="NetToHost"/>
1627
<link id="ShortHostToNet"/>
1628
<link id="ShortNetToHost"/>
1632
<!-- function Visibility: default -->
1633
<element name="NetToHost">
1634
<short>Convert a network address to a host address.</short>
1636
<var>NetToHost</var> converts a network address to a host address.
1637
It takes care of endianness of the host machine. The address can be
1638
specified as a dotted quad or as a longint.
1644
<link id="HostToNet"/>
1647
<link id="ShortHostToNet"/>
1648
<link id="ShortNetToHost"/>
1652
<!-- function Visibility: default -->
1653
<element name="ShortHostToNet">
1654
<short>Convert a host port number to a network port number</short>
1656
<var>ShortHostToNet</var> converts a host port number to a network port
1657
number. It takes care of endianness of the host machine.
1663
<link id="ShortNetToHost"/>
1664
<link id="HostToNet"/>
1670
<!-- function Visibility: default -->
1671
<element name="ShortNetToHost">
1672
<short>Convert a network port number to a host port number</short>
1674
<var>ShortNetToHost</var> converts a network port number to a host port
1675
number. It takes care of endianness of the host machine.
1681
<link id="ShortNetToHost"/>
1682
<link id="HostToNet"/>
1688
<!-- function Visibility: default -->
1689
<element name="HostAddrToStr6">
1690
<short>Convert a IPV6 host address to a string representation.</short>
1693
<var>HostAddrToStr6</var> converts the IPV6 host address in <var>Entry</var> to
1694
a string representation in human-readable form.
1697
Basically, it is the same as <link id="NetAddrToStr6"/>, but with the bytes
1702
<link id="NetAddrToStr"/>
1703
<link id="StrToHostAddr"/>
1704
<link id="StrToNetAddr"/>
1705
<link id="StrToHostAddr6"/>
1709
<!-- function Visibility: default -->
1710
<element name="StrToHostAddr6">
1711
<short>Convert a string to a IPV6 host address.</short>
1713
<var>StrToHostAddr6</var> converts the string representation in <var>IP</var>
1714
to a IPV6 host address and returns the host address.
1717
On error, the address is filled with zeroes.
1720
<link id="NetAddrToStr6"/>
1721
<link id="HostAddrToStr6"/>
1722
<link id="StrToHostAddr"/>
1726
<!-- function Visibility: default -->
1727
<element name="NetAddrToStr6">
1728
<short>Convert a IPV6 network address to a string.</short>
1731
<var>NetAddrToStr6</var> converts the IPV6 network address in <var>Entry</var> to
1732
a string representation in human-readable form.
1735
Basically, it is the same as <link id="NetAddrToStr6"/>, but with the bytes
1740
<link id="NetAddrToStr"/>
1741
<link id="StrToHostAddr"/>
1742
<link id="StrToNetAddr"/>
1743
<link id="StrToHostAddr6"/>
1747
<!-- function Visibility: default -->
1748
<element name="StrToNetAddr6">
1749
<short>Convert a string to a IPV6 network address</short>
1751
<var>StrToNetAddr6</var> converts the string representation in <var>IP</var>
1752
to a IPV6 network address and returns the network address.
1755
On error, the address is filled with zeroes.
1758
<link id="NetAddrToStr6"/>
1759
<link id="HostAddrToStr6"/>
1760
<link id="StrToHostAddr6"/>
1764
<!-- constant Visibility: default -->
1765
<element name="NoAddress">
1766
<short>Constant indicating invalid (no) network address.</short>
1769
<!-- constant Visibility: default -->
1770
<element name="NoNet">
1771
<short>Constant indicating invalid (no) network address.</short>
1774
<!-- constant Visibility: default -->
1775
<element name="NoAddress6">
1776
<short>Constant indicating invalid (no) IPV6 network address.</short>
1779
<!-- constant Visibility: default -->
1780
<element name="NoNet6">
1781
<short>Constant indicating invalid (no) IPV6 network address.</short>
1786
</fpdoc-descriptions>
b'\\ No newline at end of file'