~ubuntu-branches/ubuntu/dapper/fpc/dapper

« back to all changes in this revision

Viewing changes to packages/extra/winunits/jwawinsock.pas

  • Committer: Bazaar Package Importer
  • Author(s): Carlos Laviola
  • Date: 2005-05-30 11:59:10 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050530115910-x5pbzm4qqta4i94h
Tags: 2.0.0-2
debian/fp-compiler.postinst.in: forgot to reapply the patch that
correctly creates the slave link to pc(1).  (Closes: #310907)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{******************************************************************************}
 
2
{                                                                              }
 
3
{ Winsock API interface Unit for Object Pascal                                 }
 
4
{                                                                              }
 
5
{ Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft          }
 
6
{ Corporation. All Rights Reserved.                                            }
 
7
{                                                                              }
 
8
{ The original file is: winsock.h, released June 2000. The original Pascal     }
 
9
{ code is: WinSock.pas, released December 2000. The initial developer of the   }
 
10
{ Pascal code is Marcel van Brakel (brakelm att chello dott nl).               }
 
11
{                                                                              }
 
12
{ Portions created by Marcel van Brakel are Copyright (C) 1999-2001            }
 
13
{ Marcel van Brakel. All Rights Reserved.                                      }
 
14
{                                                                              }
 
15
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
 
16
{                                                                              }
 
17
{ You may retrieve the latest version of this file at the Project JEDI         }
 
18
{ APILIB home page, located at http://jedi-apilib.sourceforge.net              }
 
19
{                                                                              }
 
20
{ The contents of this file are used with permission, subject to the Mozilla   }
 
21
{ Public License Version 1.1 (the "License"); you may not use this file except }
 
22
{ in compliance with the License. You may obtain a copy of the License at      }
 
23
{ http://www.mozilla.org/MPL/MPL-1.1.html                                      }
 
24
{                                                                              }
 
25
{ Software distributed under the License is distributed on an "AS IS" basis,   }
 
26
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
 
27
{ the specific language governing rights and limitations under the License.    }
 
28
{                                                                              }
 
29
{ Alternatively, the contents of this file may be used under the terms of the  }
 
30
{ GNU Lesser General Public License (the  "LGPL License"), in which case the   }
 
31
{ provisions of the LGPL License are applicable instead of those above.        }
 
32
{ If you wish to allow use of your version of this file only under the terms   }
 
33
{ of the LGPL License and not to allow others to use your version of this file }
 
34
{ under the MPL, indicate your decision by deleting  the provisions above and  }
 
35
{ replace  them with the notice and other provisions required by the LGPL      }
 
36
{ License.  If you do not delete the provisions above, a recipient may use     }
 
37
{ your version of this file under either the MPL or the LGPL License.          }
 
38
{                                                                              }
 
39
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
 
40
{                                                                              }
 
41
{******************************************************************************}
 
42
 
 
43
// $Id: jwawinsock.pas,v 1.1 2005/04/04 07:56:11 marco Exp $
 
44
 
 
45
unit JwaWinSock;
 
46
 
 
47
{$WEAKPACKAGEUNIT}
 
48
 
 
49
{$HPPEMIT ''}
 
50
{$HPPEMIT '#include "winsock.h"'}
 
51
{$HPPEMIT ''}
 
52
 
 
53
{$I jediapilib.inc}
 
54
 
 
55
interface
 
56
 
 
57
uses
 
58
  JwaWinType, JwaWinBase;
 
59
 
 
60
(*
 
61
 * Basic system type definitions, taken from the BSD file sys/types.h.
 
62
 *)
 
63
 
 
64
type
 
65
  u_char = Byte;
 
66
  {$EXTERNALSYM u_char}
 
67
  u_short = Word;
 
68
  {$EXTERNALSYM u_short}
 
69
  u_int = Cardinal;
 
70
  {$EXTERNALSYM u_int}
 
71
  u_long = Cardinal;
 
72
  {$EXTERNALSYM u_long}
 
73
 
 
74
(*
 
75
 * The new type to be used in all
 
76
 * instances which refer to sockets.
 
77
 *)
 
78
 
 
79
type
 
80
  TSocket = UINT_PTR;
 
81
 
 
82
(*
 
83
 * Select uses arrays of SOCKETs.  These macros manipulate such
 
84
 * arrays.  FD_SETSIZE may be defined by the user before including
 
85
 * this file, but the default here should be >= 64.
 
86
 *
 
87
 * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE
 
88
 * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE.
 
89
 *)
 
90
 
 
91
const
 
92
  FD_SETSIZE = 64;
 
93
  {$EXTERNALSYM FD_SETSIZE}
 
94
 
 
95
type
 
96
  fd_set = record
 
97
    fd_count: u_int;                                 // how many are SET?
 
98
    fd_array: array [0..FD_SETSIZE - 1] of TSocket;   // an array of SOCKETs
 
99
  end;
 
100
  {$EXTERNALSYM fd_set}
 
101
  TFdSet = fd_set;
 
102
  PFdSet = ^fd_set;
 
103
 
 
104
function __WSAFDIsSet(s: TSocket; var FDSet: TFDSet): Integer; stdcall;
 
105
{$EXTERNALSYM __WSAFDIsSet}
 
106
 
 
107
procedure FD_CLR(fd: TSocket; var fdset: TFdSet);
 
108
{$EXTERNALSYM FD_CLR}
 
109
 
 
110
procedure _FD_SET(fd: TSocket; var fdset: TFDSet);
 
111
//{$EXTERNALSYM FD_SET}
 
112
 
 
113
procedure FD_ZERO(var fdset: TFdSet);
 
114
{$EXTERNALSYM FD_ZERO}
 
115
 
 
116
function FD_ISSET(fd: TSocket; var fdset: TFdSet): Boolean;
 
117
{$EXTERNALSYM FD_ISSET}
 
118
 
 
119
(*
 
120
 * Structure used in select() call, taken from the BSD file sys/time.h.
 
121
 *)
 
122
 
 
123
type
 
124
  timeval = record
 
125
    tv_sec: Longint;         // seconds
 
126
    tv_usec: Longint;        // and microseconds
 
127
  end;
 
128
  {$EXTERNALSYM timeval}
 
129
  TTimeVal = timeval;
 
130
  PTimeVal = ^timeval;
 
131
 
 
132
(*
 
133
 * Operations on timevals.
 
134
 *
 
135
 * NB: timercmp does not work for >= or <=.
 
136
 *)
 
137
 
 
138
function timerisset(const tvp: TTimeVal): Boolean;
 
139
{$EXTERNALSYM timerisset}
 
140
 
 
141
//function timercmp(const tvp, uvp: TTimeVal; cmp): Boolean;
 
142
//{$EXTERNALSYM timercmp}
 
143
 
 
144
procedure timerclear(var tvp: TTimeVal);
 
145
{$EXTERNALSYM timerclear}
 
146
 
 
147
(*
 
148
 * Commands for ioctlsocket(),  taken from the BSD file fcntl.h.
 
149
 *
 
150
 *
 
151
 * Ioctl's have the command encoded in the lower word,
 
152
 * and the size of any in or out parameters in the upper
 
153
 * word.  The high 2 bits of the upper word are used
 
154
 * to encode the in/out status of the parameter; for now
 
155
 * we restrict parameters to at most 128 bytes.
 
156
 *)
 
157
 
 
158
const
 
159
  IOCPARM_MASK = $7f;              // parameters must be < 128 bytes
 
160
  {$EXTERNALSYM IOCPARM_MASK}
 
161
  IOC_VOID     = $20000000;        // no parameters
 
162
  {$EXTERNALSYM IOC_VOID}
 
163
  IOC_OUT      = $40000000;        // copy out parameters
 
164
  {$EXTERNALSYM IOC_OUT}
 
165
  IOC_IN       = DWORD($80000000); // copy in parameters
 
166
  {$EXTERNALSYM IOC_IN}
 
167
  IOC_INOUT    = DWORD(IOC_IN or IOC_OUT);
 
168
  {$EXTERNALSYM IOC_INOUT}
 
169
 
 
170
  // 0x20000000 distinguishes new & old ioctl's
 
171
 
 
172
function _IO(x, y: DWORD): DWORD;
 
173
{$EXTERNALSYM _IO}
 
174
 
 
175
function _IOR(x, y, t: DWORD): DWORD;
 
176
{$EXTERNALSYM _IOR}
 
177
 
 
178
function _IOW(x, y, t: DWORD): DWORD;
 
179
{$EXTERNALSYM _IOW}
 
180
 
 
181
const
 
182
  FIONREAD = IOC_OUT or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('f') shl 8) or 127; // get # bytes to read
 
183
  {$EXTERNALSYM FIONREAD}
 
184
  FIONBIO = IOC_OUT or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('f') shl 8) or 126; // set/clear non-blocking i/o
 
185
  {$EXTERNALSYM FIONBIO}
 
186
  FIOASYNC = IOC_OUT or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('f') shl 8) or 125; // set/clear async i/o
 
187
  {$EXTERNALSYM FIOASYNC}
 
188
 
 
189
(* Socket I/O Controls *)
 
190
 
 
191
  SIOCSHIWAT = DWORD(IOC_IN or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('s') shl 8) or 0); // set high watermark
 
192
  {$EXTERNALSYM SIOCSHIWAT}
 
193
  SIOCGHIWAT = IOC_OUT or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('s') shl 8) or 1; // get high watermark
 
194
  {$EXTERNALSYM SIOCGHIWAT}
 
195
  SIOCSLOWAT = DWORD(IOC_IN or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('s') shl 8) or 2); // set low watermark
 
196
  {$EXTERNALSYM SIOCSLOWAT}
 
197
  SIOCGLOWAT = IOC_OUT or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('s') shl 8) or 3; // get low watermark
 
198
  {$EXTERNALSYM SIOCGLOWAT}
 
199
  SIOCATMARK = IOC_OUT or ((SizeOf(u_long) and IOCPARM_MASK) shl 16) or (Ord('s') shl 8) or 7; // at oob mark?
 
200
  {$EXTERNALSYM SIOCATMARK}
 
201
 
 
202
(*
 
203
 * Structures returned by network data base library, taken from the
 
204
 * BSD file netdb.h.  All addresses are supplied in host order, and
 
205
 * returned in network order (suitable for use in system calls).
 
206
 *)
 
207
 
 
208
type
 
209
  hostent = record
 
210
    h_name: PChar;           // official name of host
 
211
    h_aliases: PPChar;  // alias list
 
212
    h_addrtype: Smallint;             // host address type
 
213
    h_length: Smallint;               // length of address
 
214
    case Integer of
 
215
      0: (h_addr_list: PPChar); // list of addresses
 
216
      1: (h_addr: PPChar);          // address, for backward compat
 
217
  end;
 
218
  {$EXTERNALSYM hostent}
 
219
  THostEnt = hostent;
 
220
  PHostEnt = ^hostent;
 
221
 
 
222
(*
 
223
 * It is assumed here that a network number
 
224
 * fits in 32 bits.
 
225
 *)
 
226
 
 
227
type
 
228
  netent = record
 
229
    n_name: PChar;           // official name of net
 
230
    n_aliases: PPChar;  // alias list
 
231
    n_addrtype: Smallint;             // net address type
 
232
    n_net: u_long;                  // network #
 
233
  end;
 
234
  {$EXTERNALSYM netent}
 
235
  TNetEnt = netent;
 
236
  PNetEnt = ^netent;
 
237
 
 
238
  servent = record
 
239
    s_name: PChar;           // official service name
 
240
    s_aliases: PPChar;  // alias list
 
241
    s_port: Smallint;                 // port #
 
242
    s_proto: PChar;          // protocol to use
 
243
  end;
 
244
  {$EXTERNALSYM servent}
 
245
  TServEnt = servent;
 
246
  PServEnt = ^servent;
 
247
 
 
248
  protoent = record
 
249
    p_name: PChar;           // official protocol name
 
250
    p_aliases: PPChar;  // alias list
 
251
    p_proto: Smallint;                // protocol #
 
252
  end;
 
253
  {$EXTERNALSYM protoent}
 
254
  TProtoEnt = protoent;
 
255
  PProtoEnt = ^protoent;
 
256
 
 
257
(*
 
258
 * Constants and structures defined by the internet system,
 
259
 * Per RFC 790, September 1981, taken from the BSD file netinet/in.h.
 
260
 *)
 
261
 
 
262
(*
 
263
 * Protocols
 
264
 *)
 
265
 
 
266
const
 
267
  IPPROTO_IP   = 0; // dummy for IP
 
268
  {$EXTERNALSYM IPPROTO_IP}
 
269
  IPPROTO_ICMP = 1; // control message protocol
 
270
  {$EXTERNALSYM IPPROTO_ICMP}
 
271
  IPPROTO_IGMP = 2; // internet group management protocol
 
272
  {$EXTERNALSYM IPPROTO_IGMP}
 
273
  IPPROTO_GGP  = 3; // gateway^2 (deprecated)
 
274
  {$EXTERNALSYM IPPROTO_GGP}
 
275
  IPPROTO_TCP  = 6; // tcp
 
276
  {$EXTERNALSYM IPPROTO_TCP}
 
277
  IPPROTO_PUP  = 12; // pup
 
278
  {$EXTERNALSYM IPPROTO_PUP}
 
279
  IPPROTO_UDP  = 17; // user datagram protocol
 
280
  {$EXTERNALSYM IPPROTO_UDP}
 
281
  IPPROTO_IDP  = 22; // xns idp
 
282
  {$EXTERNALSYM IPPROTO_IDP}
 
283
  IPPROTO_ND   = 77; // UNOFFICIAL net disk proto
 
284
  {$EXTERNALSYM IPPROTO_ND}
 
285
 
 
286
  IPPROTO_RAW  = 255; // raw IP packet
 
287
  {$EXTERNALSYM IPPROTO_RAW}
 
288
  IPPROTO_MAX  = 256;
 
289
  {$EXTERNALSYM IPPROTO_MAX}
 
290
 
 
291
(*
 
292
 * Port/socket numbers: network standard functions
 
293
 *)
 
294
 
 
295
  IPPORT_ECHO       = 7;
 
296
  {$EXTERNALSYM IPPORT_ECHO}
 
297
  IPPORT_DISCARD    = 9;
 
298
  {$EXTERNALSYM IPPORT_DISCARD}
 
299
  IPPORT_SYSTAT     = 11;
 
300
  {$EXTERNALSYM IPPORT_SYSTAT}
 
301
  IPPORT_DAYTIME    = 13;
 
302
  {$EXTERNALSYM IPPORT_DAYTIME}
 
303
  IPPORT_NETSTAT    = 15;
 
304
  {$EXTERNALSYM IPPORT_NETSTAT}
 
305
  IPPORT_FTP        = 21;
 
306
  {$EXTERNALSYM IPPORT_FTP}
 
307
  IPPORT_TELNET     = 23;
 
308
  {$EXTERNALSYM IPPORT_TELNET}
 
309
  IPPORT_SMTP       = 25;
 
310
  {$EXTERNALSYM IPPORT_SMTP}
 
311
  IPPORT_TIMESERVER = 37;
 
312
  {$EXTERNALSYM IPPORT_TIMESERVER}
 
313
  IPPORT_NAMESERVER = 42;
 
314
  {$EXTERNALSYM IPPORT_NAMESERVER}
 
315
  IPPORT_WHOIS      = 43;
 
316
  {$EXTERNALSYM IPPORT_WHOIS}
 
317
  IPPORT_MTP        = 57;
 
318
  {$EXTERNALSYM IPPORT_MTP}
 
319
 
 
320
(*
 
321
 * Port/socket numbers: host specific functions
 
322
 *)
 
323
 
 
324
  IPPORT_TFTP    = 69;
 
325
  {$EXTERNALSYM IPPORT_TFTP}
 
326
  IPPORT_RJE     = 77;
 
327
  {$EXTERNALSYM IPPORT_RJE}
 
328
  IPPORT_FINGER  = 79;
 
329
  {$EXTERNALSYM IPPORT_FINGER}
 
330
  IPPORT_TTYLINK = 87;
 
331
  {$EXTERNALSYM IPPORT_TTYLINK}
 
332
  IPPORT_SUPDUP  = 95;
 
333
  {$EXTERNALSYM IPPORT_SUPDUP}
 
334
 
 
335
(*
 
336
 * UNIX TCP sockets
 
337
 *)
 
338
 
 
339
  IPPORT_EXECSERVER  = 512;
 
340
  {$EXTERNALSYM IPPORT_EXECSERVER}
 
341
  IPPORT_LOGINSERVER = 513;
 
342
  {$EXTERNALSYM IPPORT_LOGINSERVER}
 
343
  IPPORT_CMDSERVER   = 514;
 
344
  {$EXTERNALSYM IPPORT_CMDSERVER}
 
345
  IPPORT_EFSSERVER   = 520;
 
346
  {$EXTERNALSYM IPPORT_EFSSERVER}
 
347
 
 
348
(*
 
349
 * UNIX UDP sockets
 
350
 *)
 
351
 
 
352
  IPPORT_BIFFUDP     = 512;
 
353
  {$EXTERNALSYM IPPORT_BIFFUDP}
 
354
  IPPORT_WHOSERVER   = 513;
 
355
  {$EXTERNALSYM IPPORT_WHOSERVER}
 
356
  IPPORT_ROUTESERVER = 520;
 
357
  {$EXTERNALSYM IPPORT_ROUTESERVER}
 
358
 
 
359
  (* 520+1 also used *)
 
360
 
 
361
(*
 
362
 * Ports < IPPORT_RESERVED are reserved for
 
363
 * privileged processes (e.g. root).
 
364
 *)
 
365
 
 
366
  IPPORT_RESERVED = 1024;
 
367
  {$EXTERNALSYM IPPORT_RESERVED}
 
368
 
 
369
(*
 
370
 * Link numbers
 
371
 *)
 
372
 
 
373
  IMPLINK_IP        = 155;
 
374
  {$EXTERNALSYM IMPLINK_IP}
 
375
  IMPLINK_LOWEXPER  = 156;
 
376
  {$EXTERNALSYM IMPLINK_LOWEXPER}
 
377
  IMPLINK_HIGHEXPER = 158;
 
378
  {$EXTERNALSYM IMPLINK_HIGHEXPER}
 
379
 
 
380
(*
 
381
 * Internet address (old style... should be updated)
 
382
 *)
 
383
 
 
384
type
 
385
  SunB = packed record
 
386
    s_b1, s_b2, s_b3, s_b4: u_char;
 
387
  end;
 
388
  {$EXTERNALSYM SunB}
 
389
 
 
390
  SunW = packed record
 
391
    s_w1, s_w2: u_short;
 
392
  end;
 
393
  {$EXTERNALSYM SunW}
 
394
 
 
395
  in_addr = record
 
396
    case Integer of
 
397
      0: (S_un_b: SunB);
 
398
      1: (S_un_w: SunW);
 
399
      2: (S_addr: u_long);
 
400
    // #define s_addr  S_un.S_addr // can be used for most tcp & ip code
 
401
    // #define s_host  S_un.S_un_b.s_b2 // host on imp
 
402
    // #define s_net   S_un.S_un_b.s_b1  // netword
 
403
    // #define s_imp   S_un.S_un_w.s_w2 // imp
 
404
    // #define s_impno S_un.S_un_b.s_b4 // imp #
 
405
    // #define s_lh    S_un.S_un_b.s_b3 // logical host
 
406
  end;
 
407
  {$EXTERNALSYM in_addr}
 
408
  TInAddr = in_addr;
 
409
  PInAddr = ^in_addr;
 
410
 
 
411
(*
 
412
 * Definitions of bits in internet address integers.
 
413
 * On subnets, the decomposition of addresses to host and net parts
 
414
 * is done according to subnet mask, not the masks here.
 
415
 *)
 
416
 
 
417
function IN_CLASSA(i: DWORD): Boolean;
 
418
{$EXTERNALSYM IN_CLASSA}
 
419
 
 
420
const
 
421
  IN_CLASSA_NET    = DWORD($ff000000);
 
422
  {$EXTERNALSYM IN_CLASSA_NET}
 
423
  IN_CLASSA_NSHIFT = 24;
 
424
  {$EXTERNALSYM IN_CLASSA_NSHIFT}
 
425
  IN_CLASSA_HOST   = $00ffffff;
 
426
  {$EXTERNALSYM IN_CLASSA_HOST}
 
427
  IN_CLASSA_MAX    = 128;
 
428
  {$EXTERNALSYM IN_CLASSA_MAX}
 
429
 
 
430
function IN_CLASSB(i: DWORD): Boolean;
 
431
{$EXTERNALSYM IN_CLASSB}
 
432
 
 
433
const
 
434
  IN_CLASSB_NET    = DWORD($ffff0000);
 
435
  {$EXTERNALSYM IN_CLASSB_NET}
 
436
  IN_CLASSB_NSHIFT = 16;
 
437
  {$EXTERNALSYM IN_CLASSB_NSHIFT}
 
438
  IN_CLASSB_HOST   = $0000ffff;
 
439
  {$EXTERNALSYM IN_CLASSB_HOST}
 
440
  IN_CLASSB_MAX    = 65536;
 
441
  {$EXTERNALSYM IN_CLASSB_MAX}
 
442
 
 
443
function IN_CLASSC(i: DWORD): Boolean;
 
444
{$EXTERNALSYM IN_CLASSC}
 
445
 
 
446
const
 
447
  IN_CLASSC_NET    = DWORD($ffffff00);
 
448
  {$EXTERNALSYM IN_CLASSC_NET}
 
449
  IN_CLASSC_NSHIFT = 8;
 
450
  {$EXTERNALSYM IN_CLASSC_NSHIFT}
 
451
  IN_CLASSC_HOST   = $000000ff;
 
452
  {$EXTERNALSYM IN_CLASSC_HOST}
 
453
 
 
454
const
 
455
  INADDR_ANY       = u_long($00000000);
 
456
  {$EXTERNALSYM INADDR_ANY}
 
457
  INADDR_LOOPBACK  = $7f000001;
 
458
  {$EXTERNALSYM INADDR_LOOPBACK}
 
459
  INADDR_BROADCAST = u_long($ffffffff);
 
460
  {$EXTERNALSYM INADDR_BROADCAST}
 
461
  INADDR_NONE      = DWORD($ffffffff);
 
462
  {$EXTERNALSYM INADDR_NONE}
 
463
 
 
464
(*
 
465
 * Socket address, internet style.
 
466
 *)
 
467
 
 
468
type
 
469
  sockaddr_in = record
 
470
    sin_family: Smallint;
 
471
    sin_port: u_short;
 
472
    sin_addr: in_addr;
 
473
    sin_zero: array [0..7] of Char;
 
474
  end;
 
475
  {$EXTERNALSYM sockaddr_in}
 
476
  TSockAddrIn = sockaddr_in;
 
477
  PSockAddrIn = ^sockaddr_in;
 
478
 
 
479
const
 
480
  WSADESCRIPTION_LEN = 256;
 
481
  {$EXTERNALSYM WSADESCRIPTION_LEN}
 
482
  WSASYS_STATUS_LEN  = 128;
 
483
  {$EXTERNALSYM WSASYS_STATUS_LEN}
 
484
 
 
485
type
 
486
  WSAData = record
 
487
    wVersion: WORD;
 
488
    wHighVersion: WORD;
 
489
    szDescription: array [0..WSADESCRIPTION_LEN] of Char;
 
490
    szSystemStatus: array [0..WSASYS_STATUS_LEN] of Char;
 
491
    iMaxSockets: Word;
 
492
    iMaxUdpDg: Word;
 
493
    lpVendorInfo: PChar;
 
494
  end;
 
495
  {$EXTERNALSYM WSAData}
 
496
  LPWSADATA = ^WSAData;
 
497
  {$EXTERNALSYM LPWSADATA}
 
498
  TWsaData = WSAData;
 
499
  PWsaData = LPWSADATA;
 
500
 
 
501
(*
 
502
 * Options for use with [gs]etsockopt at the IP level.
 
503
 *)
 
504
 
 
505
const
 
506
  IP_OPTIONS         = 1;           (* set/get IP per-packet options    *)
 
507
  {$EXTERNALSYM IP_OPTIONS}
 
508
  IP_MULTICAST_IF    = 2;           (* set/get IP multicast interface   *)
 
509
  {$EXTERNALSYM IP_MULTICAST_IF}
 
510
  IP_MULTICAST_TTL   = 3;           (* set/get IP multicast timetolive  *)
 
511
  {$EXTERNALSYM IP_MULTICAST_TTL}
 
512
  IP_MULTICAST_LOOP  = 4;           (* set/get IP multicast loopback    *)
 
513
  {$EXTERNALSYM IP_MULTICAST_LOOP}
 
514
  IP_ADD_MEMBERSHIP  = 5;           (* add  an IP group membership      *)
 
515
  {$EXTERNALSYM IP_ADD_MEMBERSHIP}
 
516
  IP_DROP_MEMBERSHIP = 6;           (* drop an IP group membership      *)
 
517
  {$EXTERNALSYM IP_DROP_MEMBERSHIP}
 
518
  IP_TTL             = 7;           (* set/get IP Time To Live          *)
 
519
  {$EXTERNALSYM IP_TTL}
 
520
  IP_TOS             = 8;           (* set/get IP Type Of Service       *)
 
521
  {$EXTERNALSYM IP_TOS}
 
522
  IP_DONTFRAGMENT    = 9;           (* set/get IP Don't Fragment flag   *)
 
523
  {$EXTERNALSYM IP_DONTFRAGMENT}
 
524
 
 
525
  IP_DEFAULT_MULTICAST_TTL  = 1;    (* normally limit m'casts to 1 hop  *)
 
526
  {$EXTERNALSYM IP_DEFAULT_MULTICAST_TTL}
 
527
  IP_DEFAULT_MULTICAST_LOOP = 1;    (* normally hear sends if a member  *)
 
528
  {$EXTERNALSYM IP_DEFAULT_MULTICAST_LOOP}
 
529
  IP_MAX_MEMBERSHIPS        = 20;   (* per socket; must fit in one mbuf *)
 
530
  {$EXTERNALSYM IP_MAX_MEMBERSHIPS}
 
531
 
 
532
(*
 
533
 * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
 
534
 *)
 
535
 
 
536
type
 
537
  ip_mreq = record
 
538
    imr_multiaddr: in_addr;  (* IP multicast address of group *)
 
539
    mr_interface: in_addr;  (* local IP address of interface *)
 
540
  end;
 
541
  {$EXTERNALSYM ip_mreq}
 
542
  TIpMReq = ip_mreq;
 
543
  PIpMReq = ^ip_mreq;  
 
544
 
 
545
(*
 
546
 * Definitions related to sockets: types, address families, options,
 
547
 * taken from the BSD file sys/socket.h.
 
548
 *)
 
549
 
 
550
(*
 
551
 * This is used instead of -1, since the
 
552
 * SOCKET type is unsigned.
 
553
 *)
 
554
 
 
555
const
 
556
  INVALID_SOCKET = TSocket(not 0);
 
557
  {$EXTERNALSYM INVALID_SOCKET}
 
558
  SOCKET_ERROR   = -1;
 
559
  {$EXTERNALSYM SOCKET_ERROR}
 
560
 
 
561
(*
 
562
 * Types
 
563
 *)
 
564
 
 
565
  SOCK_STREAM    = 1; // stream socket
 
566
  {$EXTERNALSYM SOCK_STREAM}
 
567
  SOCK_DGRAM     = 2; // datagram socket
 
568
  {$EXTERNALSYM SOCK_DGRAM}
 
569
  SOCK_RAW       = 3; // raw-protocol interface
 
570
  {$EXTERNALSYM SOCK_RAW}
 
571
  SOCK_RDM       = 4; // reliably-delivered message
 
572
  {$EXTERNALSYM SOCK_RDM}
 
573
  SOCK_SEQPACKET = 5; // sequenced packet stream
 
574
  {$EXTERNALSYM SOCK_SEQPACKET}
 
575
 
 
576
(*
 
577
 * Option flags per-socket.
 
578
 *)
 
579
 
 
580
  SO_DEBUG       = $0001; // turn on debugging info recording
 
581
  {$EXTERNALSYM SO_DEBUG}
 
582
  SO_ACCEPTCONN  = $0002; // socket has had listen()
 
583
  {$EXTERNALSYM SO_ACCEPTCONN}
 
584
  SO_REUSEADDR   = $0004; // allow local address reuse
 
585
  {$EXTERNALSYM SO_REUSEADDR}
 
586
  SO_KEEPALIVE   = $0008; // keep connections alive
 
587
  {$EXTERNALSYM SO_KEEPALIVE}
 
588
  SO_DONTROUTE   = $0010; // just use interface addresses
 
589
  {$EXTERNALSYM SO_DONTROUTE}
 
590
  SO_BROADCAST   = $0020; // permit sending of broadcast msgs
 
591
  {$EXTERNALSYM SO_BROADCAST}
 
592
  SO_USELOOPBACK = $0040; // bypass hardware when possible
 
593
  {$EXTERNALSYM SO_USELOOPBACK}
 
594
  SO_LINGER      = $0080; // linger on close if data present
 
595
  {$EXTERNALSYM SO_LINGER}
 
596
  SO_OOBINLINE   = $0100; // leave received OOB data in line
 
597
  {$EXTERNALSYM SO_OOBINLINE}
 
598
 
 
599
  SO_DONTLINGER       = DWORD(not SO_LINGER);
 
600
  {$EXTERNALSYM SO_DONTLINGER}
 
601
 
 
602
(*
 
603
 * Additional options.
 
604
 *)
 
605
 
 
606
  SO_SNDBUF   = $1001; // send buffer size
 
607
  {$EXTERNALSYM SO_SNDBUF}
 
608
  SO_RCVBUF   = $1002; // receive buffer size
 
609
  {$EXTERNALSYM SO_RCVBUF}
 
610
  SO_SNDLOWAT = $1003; // send low-water mark
 
611
  {$EXTERNALSYM SO_SNDLOWAT}
 
612
  SO_RCVLOWAT = $1004; // receive low-water mark
 
613
  {$EXTERNALSYM SO_RCVLOWAT}
 
614
  SO_SNDTIMEO = $1005; // send timeout
 
615
  {$EXTERNALSYM SO_SNDTIMEO}
 
616
  SO_RCVTIMEO = $1006; // receive timeout
 
617
  {$EXTERNALSYM SO_RCVTIMEO}
 
618
  SO_ERROR    = $1007; // get error status and clear
 
619
  {$EXTERNALSYM SO_ERROR}
 
620
  SO_TYPE     = $1008; // get socket type
 
621
  {$EXTERNALSYM SO_TYPE}
 
622
 
 
623
(*
 
624
 * Options for connect and disconnect data and options.  Used only by
 
625
 * non-TCP/IP transports such as DECNet, OSI TP4, etc.
 
626
 *)
 
627
 
 
628
  SO_CONNDATA    = $7000;
 
629
  {$EXTERNALSYM SO_CONNDATA}
 
630
  SO_CONNOPT     = $7001;
 
631
  {$EXTERNALSYM SO_CONNOPT}
 
632
  SO_DISCDATA    = $7002;
 
633
  {$EXTERNALSYM SO_DISCDATA}
 
634
  SO_DISCOPT     = $7003;
 
635
  {$EXTERNALSYM SO_DISCOPT}
 
636
  SO_CONNDATALEN = $7004;
 
637
  {$EXTERNALSYM SO_CONNDATALEN}
 
638
  SO_CONNOPTLEN  = $7005;
 
639
  {$EXTERNALSYM SO_CONNOPTLEN}
 
640
  SO_DISCDATALEN = $7006;
 
641
  {$EXTERNALSYM SO_DISCDATALEN}
 
642
  SO_DISCOPTLEN  = $7007;
 
643
  {$EXTERNALSYM SO_DISCOPTLEN}
 
644
 
 
645
(*
 
646
 * Option for opening sockets for synchronous access.
 
647
 *)
 
648
 
 
649
  SO_OPENTYPE    = $7008;
 
650
  {$EXTERNALSYM SO_OPENTYPE}
 
651
 
 
652
  SO_SYNCHRONOUS_ALERT    = $10;
 
653
  {$EXTERNALSYM SO_SYNCHRONOUS_ALERT}
 
654
  SO_SYNCHRONOUS_NONALERT = $20;
 
655
  {$EXTERNALSYM SO_SYNCHRONOUS_NONALERT}
 
656
 
 
657
(*
 
658
 * Other NT-specific options.
 
659
 *)
 
660
 
 
661
  SO_MAXDG        = $7009;
 
662
  {$EXTERNALSYM SO_MAXDG}
 
663
  SO_MAXPATHDG    = $700A;
 
664
  {$EXTERNALSYM SO_MAXPATHDG}
 
665
  SO_UPDATE_ACCEPT_CONTEXT = $700B;
 
666
  {$EXTERNALSYM SO_UPDATE_ACCEPT_CONTEXT}
 
667
  SO_CONNECT_TIME = $700C;
 
668
  {$EXTERNALSYM SO_CONNECT_TIME}
 
669
 
 
670
(*
 
671
 * TCP options.
 
672
 *)
 
673
 
 
674
  TCP_NODELAY = $0001;
 
675
  {$EXTERNALSYM TCP_NODELAY}
 
676
  TCP_BSDURGENT = $7000;
 
677
  {$EXTERNALSYM TCP_BSDURGENT}
 
678
 
 
679
(*
 
680
 * Address families.
 
681
 *)
 
682
 
 
683
  AF_UNSPEC = 0; // unspecified
 
684
  {$EXTERNALSYM AF_UNSPEC}
 
685
  AF_UNIX      = 1; // local to host (pipes, portals
 
686
  {$EXTERNALSYM AF_UNIX}
 
687
  AF_INET      = 2; // internetwork: UDP, TCP, etc.
 
688
  {$EXTERNALSYM AF_INET}
 
689
  AF_IMPLINK   = 3; // arpanet imp addresses
 
690
  {$EXTERNALSYM AF_IMPLINK}
 
691
  AF_PUP       = 4; // pup protocols: e.g. BSP
 
692
  {$EXTERNALSYM AF_PUP}
 
693
  AF_CHAOS     = 5; // mit CHAOS protocols
 
694
  {$EXTERNALSYM AF_CHAOS}
 
695
  AF_NS        = 6; // XEROX NS protocols
 
696
  {$EXTERNALSYM AF_NS}
 
697
  AF_IPX       = AF_NS; // IPX protocols: IPX, SPX, etc.
 
698
  {$EXTERNALSYM AF_IPX}
 
699
  AF_ISO       = 7; // ISO protocols
 
700
  {$EXTERNALSYM AF_ISO}
 
701
  AF_OSI       = AF_ISO; // OSI is ISO
 
702
  {$EXTERNALSYM AF_OSI}
 
703
  AF_ECMA      = 8; // european computer manufacturers
 
704
  {$EXTERNALSYM AF_ECMA}
 
705
  AF_DATAKIT   = 9; // datakit protocols
 
706
  {$EXTERNALSYM AF_DATAKIT}
 
707
  AF_CCITT     = 10; // CCITT protocols, X.25 etc
 
708
  {$EXTERNALSYM AF_CCITT}
 
709
  AF_SNA       = 11; // IBM SNA
 
710
  {$EXTERNALSYM AF_SNA}
 
711
  AF_DECnet    = 12; // DECnet
 
712
  {$EXTERNALSYM AF_DECnet}
 
713
  AF_DLI       = 13; // Direct data link interface
 
714
  {$EXTERNALSYM AF_DLI}
 
715
  AF_LAT       = 14; // LAT
 
716
  {$EXTERNALSYM AF_LAT}
 
717
  AF_HYLINK    = 15; // NSC Hyperchannel
 
718
  {$EXTERNALSYM AF_HYLINK}
 
719
  AF_APPLETALK = 16; // AppleTalk
 
720
  {$EXTERNALSYM AF_APPLETALK}
 
721
  AF_NETBIOS   = 17; // NetBios-style addresses
 
722
  {$EXTERNALSYM AF_NETBIOS}
 
723
  AF_VOICEVIEW = 18; // VoiceView
 
724
  {$EXTERNALSYM AF_VOICEVIEW}
 
725
  AF_FIREFOX   = 19; // Protocols from Firefox
 
726
  {$EXTERNALSYM AF_FIREFOX}
 
727
  AF_UNKNOWN1  = 20; // Somebody is using this!
 
728
  {$EXTERNALSYM AF_UNKNOWN1}
 
729
  AF_BAN       = 21; // Banyan
 
730
  {$EXTERNALSYM AF_BAN}
 
731
 
 
732
  AF_MAX = 22;
 
733
  {$EXTERNALSYM AF_MAX}
 
734
 
 
735
(*
 
736
 * Structure used by kernel to store most
 
737
 * addresses.
 
738
 *)
 
739
 
 
740
type
 
741
  sockaddr = record
 
742
    sa_family: u_short;              // address family
 
743
    sa_data: array [0..13] of Char;            // up to 14 bytes of direct address
 
744
  end;
 
745
  {$EXTERNALSYM sockaddr}
 
746
  TSockAddr = sockaddr;
 
747
  PSockAddr = ^sockaddr;
 
748
 
 
749
(*
 
750
 * Structure used by kernel to pass protocol
 
751
 * information in raw sockets.
 
752
 *)
 
753
 
 
754
  sockproto = record
 
755
    sp_family: u_short;              // address family
 
756
    sp_protocol: u_short;            // protocol
 
757
  end;
 
758
  {$EXTERNALSYM sockproto}
 
759
  TSockProto = sockproto;
 
760
  PSockProto = ^sockproto;
 
761
 
 
762
(*
 
763
 * Protocol families, same as address families for now.
 
764
 *)
 
765
 
 
766
const
 
767
  PF_UNSPEC    = AF_UNSPEC;
 
768
  {$EXTERNALSYM PF_UNSPEC}
 
769
  PF_UNIX      = AF_UNIX;
 
770
  {$EXTERNALSYM PF_UNIX}
 
771
  PF_INET      = AF_INET;
 
772
  {$EXTERNALSYM PF_INET}
 
773
  PF_IMPLINK   = AF_IMPLINK;
 
774
  {$EXTERNALSYM PF_IMPLINK}
 
775
  PF_PUP       = AF_PUP;
 
776
  {$EXTERNALSYM PF_PUP}
 
777
  PF_CHAOS     = AF_CHAOS;
 
778
  {$EXTERNALSYM PF_CHAOS}
 
779
  PF_NS        = AF_NS;
 
780
  {$EXTERNALSYM PF_NS}
 
781
  PF_IPX       = AF_IPX;
 
782
  {$EXTERNALSYM PF_IPX}
 
783
  PF_ISO       = AF_ISO;
 
784
  {$EXTERNALSYM PF_ISO}
 
785
  PF_OSI       = AF_OSI;
 
786
  {$EXTERNALSYM PF_OSI}
 
787
  PF_ECMA      = AF_ECMA;
 
788
  {$EXTERNALSYM PF_ECMA}
 
789
  PF_DATAKIT   = AF_DATAKIT;
 
790
  {$EXTERNALSYM PF_DATAKIT}
 
791
  PF_CCITT     = AF_CCITT;
 
792
  {$EXTERNALSYM PF_CCITT}
 
793
  PF_SNA       = AF_SNA;
 
794
  {$EXTERNALSYM PF_SNA}
 
795
  PF_DECnet    = AF_DECnet;
 
796
  {$EXTERNALSYM PF_DECnet}
 
797
  PF_DLI       = AF_DLI;
 
798
  {$EXTERNALSYM PF_DLI}
 
799
  PF_LAT       = AF_LAT;
 
800
  {$EXTERNALSYM PF_LAT}
 
801
  PF_HYLINK    = AF_HYLINK;
 
802
  {$EXTERNALSYM PF_HYLINK}
 
803
  PF_APPLETALK = AF_APPLETALK;
 
804
  {$EXTERNALSYM PF_APPLETALK}
 
805
  PF_VOICEVIEW = AF_VOICEVIEW;
 
806
  {$EXTERNALSYM PF_VOICEVIEW}
 
807
  PF_FIREFOX   = AF_FIREFOX;
 
808
  {$EXTERNALSYM PF_FIREFOX}
 
809
  PF_UNKNOWN1  = AF_UNKNOWN1;
 
810
  {$EXTERNALSYM PF_UNKNOWN1}
 
811
  PF_BAN       = AF_BAN;
 
812
  {$EXTERNALSYM PF_BAN}
 
813
 
 
814
  PF_MAX = AF_MAX;
 
815
  {$EXTERNALSYM PF_MAX}
 
816
 
 
817
(*
 
818
 * Structure used for manipulating linger option.
 
819
 *)
 
820
 
 
821
type
 
822
  linger = record
 
823
    l_onoff: u_short;                // option on/off
 
824
    l_linger: u_short;               // linger time
 
825
  end;
 
826
  {$EXTERNALSYM linger}
 
827
  TLinger = linger;
 
828
  PLinger = ^linger;
 
829
 
 
830
(*
 
831
 * Level number for (get/set)sockopt() to apply to socket itself.
 
832
 *)
 
833
 
 
834
const
 
835
  SOL_SOCKET = $ffff; // options for socket level
 
836
  {$EXTERNALSYM SOL_SOCKET}
 
837
 
 
838
(*
 
839
 * Maximum queue length specifiable by listen.
 
840
 *)
 
841
 
 
842
  SOMAXCONN = $7fffffff;
 
843
  {$EXTERNALSYM SOMAXCONN}
 
844
 
 
845
  MSG_OOB       = $1; // process out-of-band data
 
846
  {$EXTERNALSYM MSG_OOB}
 
847
  MSG_PEEK      = $2; // peek at incoming message
 
848
  {$EXTERNALSYM MSG_PEEK}
 
849
  MSG_DONTROUTE = $4; // send without using routing tables
 
850
  {$EXTERNALSYM MSG_DONTROUTE}
 
851
 
 
852
  MSG_MAXIOVLEN = 16;
 
853
  {$EXTERNALSYM MSG_MAXIOVLEN}
 
854
 
 
855
  MSG_PARTIAL   = $8000; // partial send or recv for message xport
 
856
  {$EXTERNALSYM MSG_PARTIAL}
 
857
 
 
858
(*
 
859
 * Define constant based on rfc883, used by gethostbyxxxx() calls.
 
860
 *)
 
861
 
 
862
  MAXGETHOSTSTRUCT = 1024;
 
863
  {$EXTERNALSYM MAXGETHOSTSTRUCT}
 
864
 
 
865
(*
 
866
 * Define flags to be used with the WSAAsyncSelect() call.
 
867
 *)
 
868
 
 
869
  FD_READ        = $01;
 
870
  {$EXTERNALSYM FD_READ}
 
871
  FD_WRITE       = $02;
 
872
  {$EXTERNALSYM FD_WRITE}
 
873
  FD_OOB         = $04;
 
874
  {$EXTERNALSYM FD_OOB}
 
875
  FD_ACCEPT      = $08;
 
876
  {$EXTERNALSYM FD_ACCEPT}
 
877
  FD_CONNECT     = $10;
 
878
  {$EXTERNALSYM FD_CONNECT}
 
879
  FD_CLOSE       = $20;
 
880
  {$EXTERNALSYM FD_CLOSE}
 
881
 
 
882
(*
 
883
 * All Windows Sockets error constants are biased by WSABASEERR from
 
884
 * the "normal"
 
885
 *)
 
886
 
 
887
  WSABASEERR = 10000;
 
888
  {$EXTERNALSYM WSABASEERR}
 
889
 
 
890
(*
 
891
 * Windows Sockets definitions of regular Microsoft C error constants
 
892
 *)
 
893
 
 
894
  WSAEINTR  = WSABASEERR + 4;
 
895
  {$EXTERNALSYM WSAEINTR}
 
896
  WSAEBADF  = WSABASEERR + 9;
 
897
  {$EXTERNALSYM WSAEBADF}
 
898
  WSAEACCES = WSABASEERR + 13;
 
899
  {$EXTERNALSYM WSAEACCES}
 
900
  WSAEFAULT = WSABASEERR + 14;
 
901
  {$EXTERNALSYM WSAEFAULT}
 
902
  WSAEINVAL = WSABASEERR + 22;
 
903
  {$EXTERNALSYM WSAEINVAL}
 
904
  WSAEMFILE = WSABASEERR + 24;
 
905
  {$EXTERNALSYM WSAEMFILE}
 
906
 
 
907
(*
 
908
 * Windows Sockets definitions of regular Berkeley error constants
 
909
 *)
 
910
 
 
911
  WSAEWOULDBLOCK     = WSABASEERR + 35;
 
912
  {$EXTERNALSYM WSAEWOULDBLOCK}
 
913
  WSAEINPROGRESS     = WSABASEERR + 36;
 
914
  {$EXTERNALSYM WSAEINPROGRESS}
 
915
  WSAEALREADY        = WSABASEERR + 37;
 
916
  {$EXTERNALSYM WSAEALREADY}
 
917
  WSAENOTSOCK        = WSABASEERR + 38;
 
918
  {$EXTERNALSYM WSAENOTSOCK}
 
919
  WSAEDESTADDRREQ    = WSABASEERR + 39;
 
920
  {$EXTERNALSYM WSAEDESTADDRREQ}
 
921
  WSAEMSGSIZE        = WSABASEERR + 40;
 
922
  {$EXTERNALSYM WSAEMSGSIZE}
 
923
  WSAEPROTOTYPE      = WSABASEERR + 41;
 
924
  {$EXTERNALSYM WSAEPROTOTYPE}
 
925
  WSAENOPROTOOPT     = WSABASEERR + 42;
 
926
  {$EXTERNALSYM WSAENOPROTOOPT}
 
927
  WSAEPROTONOSUPPORT = WSABASEERR + 43;
 
928
  {$EXTERNALSYM WSAEPROTONOSUPPORT}
 
929
  WSAESOCKTNOSUPPORT = WSABASEERR + 44;
 
930
  {$EXTERNALSYM WSAESOCKTNOSUPPORT}
 
931
  WSAEOPNOTSUPP      = WSABASEERR + 45;
 
932
  {$EXTERNALSYM WSAEOPNOTSUPP}
 
933
  WSAEPFNOSUPPORT    = WSABASEERR + 46;
 
934
  {$EXTERNALSYM WSAEPFNOSUPPORT}
 
935
  WSAEAFNOSUPPORT    = WSABASEERR + 47;
 
936
  {$EXTERNALSYM WSAEAFNOSUPPORT}
 
937
  WSAEADDRINUSE      = WSABASEERR + 48;
 
938
  {$EXTERNALSYM WSAEADDRINUSE}
 
939
  WSAEADDRNOTAVAIL   = WSABASEERR + 49;
 
940
  {$EXTERNALSYM WSAEADDRNOTAVAIL}
 
941
  WSAENETDOWN        = WSABASEERR + 50;
 
942
  {$EXTERNALSYM WSAENETDOWN}
 
943
  WSAENETUNREACH     = WSABASEERR + 51;
 
944
  {$EXTERNALSYM WSAENETUNREACH}
 
945
  WSAENETRESET       = WSABASEERR + 52;
 
946
  {$EXTERNALSYM WSAENETRESET}
 
947
  WSAECONNABORTED    = WSABASEERR + 53;
 
948
  {$EXTERNALSYM WSAECONNABORTED}
 
949
  WSAECONNRESET      = WSABASEERR + 54;
 
950
  {$EXTERNALSYM WSAECONNRESET}
 
951
  WSAENOBUFS         = WSABASEERR + 55;
 
952
  {$EXTERNALSYM WSAENOBUFS}
 
953
  WSAEISCONN         = WSABASEERR + 56;
 
954
  {$EXTERNALSYM WSAEISCONN}
 
955
  WSAENOTCONN        = WSABASEERR + 57;
 
956
  {$EXTERNALSYM WSAENOTCONN}
 
957
  WSAESHUTDOWN       = WSABASEERR + 58;
 
958
  {$EXTERNALSYM WSAESHUTDOWN}
 
959
  WSAETOOMANYREFS    = WSABASEERR + 59;
 
960
  {$EXTERNALSYM WSAETOOMANYREFS}
 
961
  WSAETIMEDOUT       = WSABASEERR + 60;
 
962
  {$EXTERNALSYM WSAETIMEDOUT}
 
963
  WSAECONNREFUSED    = WSABASEERR + 61;
 
964
  {$EXTERNALSYM WSAECONNREFUSED}
 
965
  WSAELOOP           = WSABASEERR + 62;
 
966
  {$EXTERNALSYM WSAELOOP}
 
967
  WSAENAMETOOLONG    = WSABASEERR + 63;
 
968
  {$EXTERNALSYM WSAENAMETOOLONG}
 
969
  WSAEHOSTDOWN       = WSABASEERR + 64;
 
970
  {$EXTERNALSYM WSAEHOSTDOWN}
 
971
  WSAEHOSTUNREACH    = WSABASEERR + 65;
 
972
  {$EXTERNALSYM WSAEHOSTUNREACH}
 
973
  WSAENOTEMPTY       = WSABASEERR + 66;
 
974
  {$EXTERNALSYM WSAENOTEMPTY}
 
975
  WSAEPROCLIM        = WSABASEERR + 67;
 
976
  {$EXTERNALSYM WSAEPROCLIM}
 
977
  WSAEUSERS          = WSABASEERR + 68;
 
978
  {$EXTERNALSYM WSAEUSERS}
 
979
  WSAEDQUOT          = WSABASEERR + 69;
 
980
  {$EXTERNALSYM WSAEDQUOT}
 
981
  WSAESTALE          = WSABASEERR + 70;
 
982
  {$EXTERNALSYM WSAESTALE}
 
983
  WSAEREMOTE         = WSABASEERR + 71;
 
984
  {$EXTERNALSYM WSAEREMOTE}
 
985
 
 
986
  WSAEDISCON         = WSABASEERR + 101;
 
987
  {$EXTERNALSYM WSAEDISCON}
 
988
 
 
989
(*
 
990
 * Extended Windows Sockets error constant definitions
 
991
 *)
 
992
 
 
993
  WSASYSNOTREADY         = WSABASEERR + 91;
 
994
  {$EXTERNALSYM WSASYSNOTREADY}
 
995
  WSAVERNOTSUPPORTED     = WSABASEERR + 92;
 
996
  {$EXTERNALSYM WSAVERNOTSUPPORTED}
 
997
  WSANOTINITIALISED      = WSABASEERR + 93;
 
998
  {$EXTERNALSYM WSANOTINITIALISED}
 
999
 
 
1000
(*
 
1001
 * Error return codes from gethostbyname() and gethostbyaddr()
 
1002
 * (when using the resolver). Note that these errors are
 
1003
 * retrieved via WSAGetLastError() and must therefore follow
 
1004
 * the rules for avoiding clashes with error numbers from
 
1005
 * specific implementations or language run-time systems.
 
1006
 * For this reason the codes are based at WSABASEERR+1001.
 
1007
 * Note also that [WSA]NO_ADDRESS is defined only for
 
1008
 * compatibility purposes.
 
1009
 *)
 
1010
 
 
1011
// Authoritative Answer: Host not found
 
1012
 
 
1013
  WSAHOST_NOT_FOUND = WSABASEERR + 1001;
 
1014
  {$EXTERNALSYM WSAHOST_NOT_FOUND}
 
1015
 
 
1016
// Non-Authoritative: Host not found, or SERVERFAIL
 
1017
 
 
1018
  WSATRY_AGAIN = WSABASEERR + 1002;
 
1019
  {$EXTERNALSYM WSATRY_AGAIN}
 
1020
 
 
1021
// Non-recoverable errors, FORMERR, REFUSED, NOTIMP
 
1022
 
 
1023
  WSANO_RECOVERY = WSABASEERR + 1003;
 
1024
  {$EXTERNALSYM WSANO_RECOVERY}
 
1025
 
 
1026
// Valid name, no data record of requested type
 
1027
 
 
1028
  WSANO_DATA = WSABASEERR + 1004;
 
1029
  {$EXTERNALSYM WSANO_DATA}
 
1030
 
 
1031
(*
 
1032
 * Compatibility macros.
 
1033
 *)
 
1034
 
 
1035
function h_errno: Integer;
 
1036
{$EXTERNALSYM h_errno}
 
1037
 
 
1038
const
 
1039
  HOST_NOT_FOUND = WSAHOST_NOT_FOUND;
 
1040
  {$EXTERNALSYM HOST_NOT_FOUND}
 
1041
  TRY_AGAIN      = WSATRY_AGAIN;
 
1042
  {$EXTERNALSYM TRY_AGAIN}
 
1043
  NO_RECOVERY    = WSANO_RECOVERY;
 
1044
  {$EXTERNALSYM NO_RECOVERY}
 
1045
  NO_DATA        = WSANO_DATA;
 
1046
  {$EXTERNALSYM NO_DATA}
 
1047
 
 
1048
// no address, look for MX record
 
1049
 
 
1050
  WSANO_ADDRESS = WSANO_DATA;
 
1051
  {$EXTERNALSYM WSANO_ADDRESS}
 
1052
  NO_ADDRESS    = WSANO_ADDRESS;
 
1053
  {$EXTERNALSYM NO_ADDRESS}
 
1054
 
 
1055
(*
 
1056
 * Windows Sockets errors redefined as regular Berkeley error constants.
 
1057
 * These are commented out in Windows NT to avoid conflicts with errno.h.
 
1058
 * Use the WSA constants instead.
 
1059
 *)
 
1060
 
 
1061
{$IFDEF FALSE}
 
1062
 
 
1063
const
 
1064
  EWOULDBLOCK     = WSAEWOULDBLOCK;
 
1065
  {$EXTERNALSYM EWOULDBLOCK}
 
1066
  EINPROGRESS     = WSAEINPROGRESS;
 
1067
  {$EXTERNALSYM EINPROGRESS}
 
1068
  EALREADY        = WSAEALREADY;
 
1069
  {$EXTERNALSYM EALREADY}
 
1070
  ENOTSOCK        = WSAENOTSOCK;
 
1071
  {$EXTERNALSYM ENOTSOCK}
 
1072
  EDESTADDRREQ    = WSAEDESTADDRREQ;
 
1073
  {$EXTERNALSYM EDESTADDRREQ}
 
1074
  EMSGSIZE        = WSAEMSGSIZE;
 
1075
  {$EXTERNALSYM EMSGSIZE}
 
1076
  EPROTOTYPE      = WSAEPROTOTYPE;
 
1077
  {$EXTERNALSYM EPROTOTYPE}
 
1078
  ENOPROTOOPT     = WSAENOPROTOOPT;
 
1079
  {$EXTERNALSYM ENOPROTOOPT}
 
1080
  EPROTONOSUPPORT = WSAEPROTONOSUPPORT;
 
1081
  {$EXTERNALSYM EPROTONOSUPPORT}
 
1082
  ESOCKTNOSUPPORT = WSAESOCKTNOSUPPORT;
 
1083
  {$EXTERNALSYM ESOCKTNOSUPPORT}
 
1084
  EOPNOTSUPP      = WSAEOPNOTSUPP;
 
1085
  {$EXTERNALSYM EOPNOTSUPP}
 
1086
  EPFNOSUPPORT    = WSAEPFNOSUPPORT;
 
1087
  {$EXTERNALSYM EPFNOSUPPORT}
 
1088
  EAFNOSUPPORT    = WSAEAFNOSUPPORT;
 
1089
  {$EXTERNALSYM EAFNOSUPPORT}
 
1090
  EADDRINUSE      = WSAEADDRINUSE;
 
1091
  {$EXTERNALSYM EADDRINUSE}
 
1092
  EADDRNOTAVAIL   = WSAEADDRNOTAVAIL;
 
1093
  {$EXTERNALSYM EADDRNOTAVAIL}
 
1094
  ENETDOWN        = WSAENETDOWN;
 
1095
  {$EXTERNALSYM ENETDOWN}
 
1096
  ENETUNREACH     = WSAENETUNREACH;
 
1097
  {$EXTERNALSYM ENETUNREACH}
 
1098
  ENETRESET       = WSAENETRESET;
 
1099
  {$EXTERNALSYM ENETRESET}
 
1100
  ECONNABORTED    = WSAECONNABORTED;
 
1101
  {$EXTERNALSYM ECONNABORTED}
 
1102
  ECONNRESET      = WSAECONNRESET;
 
1103
  {$EXTERNALSYM ECONNRESET}
 
1104
  ENOBUFS         = WSAENOBUFS;
 
1105
  {$EXTERNALSYM ENOBUFS}
 
1106
  EISCONN         = WSAEISCONN;
 
1107
  {$EXTERNALSYM EISCONN}
 
1108
  ENOTCONN        = WSAENOTCONN;
 
1109
  {$EXTERNALSYM ENOTCONN}
 
1110
  ESHUTDOWN       = WSAESHUTDOWN;
 
1111
  {$EXTERNALSYM ESHUTDOWN}
 
1112
  ETOOMANYREFS    = WSAETOOMANYREFS;
 
1113
  {$EXTERNALSYM ETOOMANYREFS}
 
1114
  ETIMEDOUT       = WSAETIMEDOUT;
 
1115
  {$EXTERNALSYM ETIMEDOUT}
 
1116
  ECONNREFUSED    = WSAECONNREFUSED;
 
1117
  {$EXTERNALSYM ECONNREFUSED}
 
1118
  ELOOP           = WSAELOOP;
 
1119
  {$EXTERNALSYM ELOOP}
 
1120
  ENAMETOOLONG    = WSAENAMETOOLONG;
 
1121
  {$EXTERNALSYM ENAMETOOLONG}
 
1122
  EHOSTDOWN       = WSAEHOSTDOWN;
 
1123
  {$EXTERNALSYM EHOSTDOWN}
 
1124
  EHOSTUNREACH    = WSAEHOSTUNREACH;
 
1125
  {$EXTERNALSYM EHOSTUNREACH}
 
1126
  ENOTEMPTY       = WSAENOTEMPTY;
 
1127
  {$EXTERNALSYM ENOTEMPTY}
 
1128
  EPROCLIM        = WSAEPROCLIM;
 
1129
  {$EXTERNALSYM EPROCLIM}
 
1130
  EUSERS          = WSAEUSERS;
 
1131
  {$EXTERNALSYM EUSERS}
 
1132
  EDQUOT          = WSAEDQUOT;
 
1133
  {$EXTERNALSYM EDQUOT}
 
1134
  ESTALE          = WSAESTALE;
 
1135
  {$EXTERNALSYM ESTALE}
 
1136
  EREMOTE         = WSAEREMOTE;
 
1137
  {$EXTERNALSYM EREMOTE}
 
1138
 
 
1139
{$ENDIF FALSE}
 
1140
 
 
1141
(* Socket function prototypes *)
 
1142
 
 
1143
function accept(s: TSocket; addr: PSockAddr; addrlen: PINT): TSocket; stdcall;
 
1144
{$EXTERNALSYM accept}
 
1145
function bind(s: TSocket; name: PSockAddr; namelen: Integer): Integer; stdcall;
 
1146
{$EXTERNALSYM bind}
 
1147
function closesocket(s: TSocket): Integer; stdcall;
 
1148
{$EXTERNALSYM closesocket}
 
1149
function connect(s: TSocket; name: PSockAddr; namelen: Integer): Integer; stdcall;
 
1150
{$EXTERNALSYM connect}
 
1151
function ioctlsocket(s: TSocket; cmd: Longint; var argp: u_long): Integer; stdcall;
 
1152
{$EXTERNALSYM ioctlsocket}
 
1153
function getpeername(s: TSocket; name: PSockAddr; var namelen: Integer): Integer; stdcall;
 
1154
{$EXTERNALSYM getpeername}
 
1155
function getsockname(s: TSocket; name: PSockAddr; var namelen: Integer): Integer; stdcall;
 
1156
{$EXTERNALSYM getsockname}
 
1157
function getsockopt(s: TSocket; level, optname: Integer; optval: PChar; var optlen: Integer): Integer; stdcall;
 
1158
{$EXTERNALSYM getsockopt}
 
1159
function htonl(hostlong: u_long): u_long; stdcall;
 
1160
{$EXTERNALSYM htonl}
 
1161
function htons(hostshort: u_short): u_short; stdcall;
 
1162
{$EXTERNALSYM htons}
 
1163
function inet_addr(cp: PChar): u_long; stdcall;
 
1164
{$EXTERNALSYM inet_addr}
 
1165
function inet_ntoa(inaddr: in_addr): PChar; stdcall;
 
1166
{$EXTERNALSYM inet_ntoa}
 
1167
function listen(s: TSocket; backlog: Integer): Integer; stdcall;
 
1168
{$EXTERNALSYM listen}
 
1169
function ntohl(netlong: u_long): u_long; stdcall;
 
1170
{$EXTERNALSYM ntohl}
 
1171
function ntohs(netshort: u_short): u_short; stdcall;
 
1172
{$EXTERNALSYM ntohs}
 
1173
function recv(s: TSocket; var buf; len, flags: Integer): Integer; stdcall;
 
1174
{$EXTERNALSYM recv}
 
1175
function recvfrom(s: TSocket; var buf; len, flags: Integer; from: PSockAddr; var fromlen: Integer): Integer; stdcall;
 
1176
{$EXTERNALSYM recvfrom}
 
1177
function select(nfds: Integer; readfds, writefds, exceptfds: PFdSet; timeout: PTimeVal): Integer; stdcall;
 
1178
{$EXTERNALSYM select}
 
1179
function send(s: TSocket; var buf; len, flags: Integer): Integer; stdcall;
 
1180
{$EXTERNALSYM send}
 
1181
function sendto(s: TSocket; var buf; len, flags: Integer; toaddr: PSockAddr; tolen: Integer): Integer; stdcall;
 
1182
{$EXTERNALSYM sendto}
 
1183
function setsockopt(s: TSocket; level, optname: Integer; optval: PChar; optlen: Integer): Integer; stdcall;
 
1184
{$EXTERNALSYM setsockopt}
 
1185
function shutdown(s: TSocket; how: Integer): Integer; stdcall;
 
1186
{$EXTERNALSYM shutdown}
 
1187
function socket(af, type_, protocol: Integer): TSocket; stdcall;
 
1188
{$EXTERNALSYM socket}
 
1189
 
 
1190
(* Database function prototypes *)
 
1191
 
 
1192
function gethostbyaddr(addr: PChar; len, type_: Integer): PHostEnt; stdcall;
 
1193
{$EXTERNALSYM gethostbyaddr}
 
1194
function gethostbyname(name: PChar): PHostEnt; stdcall;
 
1195
{$EXTERNALSYM gethostbyname}
 
1196
function gethostname(name: PChar; namelen: Integer): Integer; stdcall;
 
1197
{$EXTERNALSYM gethostname}
 
1198
function getservbyport(port: Integer; proto: PChar): PServEnt; stdcall;
 
1199
{$EXTERNALSYM getservbyport}
 
1200
function getservbyname(name, proto: PChar): PServEnt; stdcall;
 
1201
{$EXTERNALSYM getservbyname}
 
1202
function getprotobynumber(number: Integer): PProtoEnt; stdcall;
 
1203
{$EXTERNALSYM getprotobynumber}
 
1204
function getprotobyname(name: PChar): PProtoEnt; stdcall;
 
1205
{$EXTERNALSYM getprotobyname}
 
1206
 
 
1207
(* Microsoft Windows Extension function prototypes *)
 
1208
 
 
1209
function WSAStartup(wVersionRequired: WORD; var lpWSAData: TWSAData): Integer; stdcall;
 
1210
{$EXTERNALSYM WSAStartup}
 
1211
function WSACleanup: Integer; stdcall;
 
1212
{$EXTERNALSYM WSACleanup}
 
1213
procedure WSASetLastError(iError: Integer); stdcall;
 
1214
{$EXTERNALSYM WSASetLastError}
 
1215
function WSAGetLastError: Integer; stdcall;
 
1216
{$EXTERNALSYM WSAGetLastError}
 
1217
function WSAIsBlocking: BOOL; stdcall;
 
1218
{$EXTERNALSYM WSAIsBlocking}
 
1219
function WSAUnhookBlockingHook: Integer; stdcall;
 
1220
{$EXTERNALSYM WSAUnhookBlockingHook}
 
1221
function WSASetBlockingHook(lpBlockFunc: FARPROC): FARPROC; stdcall;
 
1222
{$EXTERNALSYM WSASetBlockingHook}
 
1223
function WSACancelBlockingCall: Integer; stdcall;
 
1224
{$EXTERNALSYM WSACancelBlockingCall}
 
1225
function WSAAsyncGetServByName(hWnd: HWND; wMsg: u_int; name, proto, buf: PChar;
 
1226
  buflen: Integer): HANDLE; stdcall;
 
1227
{$EXTERNALSYM WSAAsyncGetServByName}
 
1228
function WSAAsyncGetServByPort(hWnd: HWND; wMsg: u_int; port: Integer;
 
1229
  proto, buf: PChar; buflen: Integer): HANDLE; stdcall;
 
1230
{$EXTERNALSYM WSAAsyncGetServByPort}
 
1231
function WSAAsyncGetProtoByName(hWnd: HWND; wMsg: u_int; name, buf: PChar;
 
1232
  buflen: Integer): HANDLE; stdcall;
 
1233
{$EXTERNALSYM WSAAsyncGetProtoByName}
 
1234
function WSAAsyncGetProtoByNumber(hWnd: HWND; wMsg: u_int; number: Integer;
 
1235
  buf: PChar; buflen: Integer): HANDLE; stdcall;
 
1236
{$EXTERNALSYM WSAAsyncGetProtoByNumber}
 
1237
function WSAAsyncGetHostByName(hWnd: HWND; wMsg: u_int; name, buf: PChar;
 
1238
  buflen: Integer): HANDLE; stdcall;
 
1239
{$EXTERNALSYM WSAAsyncGetHostByName}
 
1240
function WSAAsyncGetHostByAddr(hWnd: HWND; wMsg: u_int; addr: PChar;
 
1241
  len, type_: Integer; buf: PChar; buflen: Integer): HANDLE; stdcall;
 
1242
{$EXTERNALSYM WSAAsyncGetHostByAddr}
 
1243
function WSACancelAsyncRequest(hAsyncTaskHandle: HANDLE): Integer; stdcall;
 
1244
{$EXTERNALSYM WSACancelAsyncRequest}
 
1245
function WSAAsyncSelect(s: TSocket; hWnd: HWND; wMsg: u_int; lEvent: Longint): Integer; stdcall;
 
1246
{$EXTERNALSYM WSAAsyncSelect}
 
1247
 
 
1248
function WSARecvEx(s: TSocket; var buf; len: Integer; var flags: Integer): Integer; stdcall;
 
1249
{$EXTERNALSYM WSARecvEx}
 
1250
 
 
1251
type
 
1252
  _TRANSMIT_FILE_BUFFERS = record
 
1253
    Head: LPVOID;
 
1254
    HeadLength: DWORD;
 
1255
    Tail: LPVOID;
 
1256
    TailLength: DWORD;
 
1257
  end;
 
1258
  {$EXTERNALSYM _TRANSMIT_FILE_BUFFERS}
 
1259
  TRANSMIT_FILE_BUFFERS = _TRANSMIT_FILE_BUFFERS;
 
1260
  {$EXTERNALSYM TRANSMIT_FILE_BUFFERS}
 
1261
  PTRANSMIT_FILE_BUFFERS = ^TRANSMIT_FILE_BUFFERS;
 
1262
  {$EXTERNALSYM PTRANSMIT_FILE_BUFFERS}
 
1263
  LPTRANSMIT_FILE_BUFFERS = ^TRANSMIT_FILE_BUFFERS;
 
1264
  {$EXTERNALSYM LPTRANSMIT_FILE_BUFFERS}
 
1265
  TTransmitFileBuffers = TRANSMIT_FILE_BUFFERS;
 
1266
  PTransmitFileBuffers = LPTRANSMIT_FILE_BUFFERS;
 
1267
 
 
1268
const
 
1269
  TF_DISCONNECT           = $01;
 
1270
  {$EXTERNALSYM TF_DISCONNECT}
 
1271
  TF_REUSE_SOCKET         = $02;
 
1272
  {$EXTERNALSYM TF_REUSE_SOCKET}
 
1273
  TF_WRITE_BEHIND         = $04;
 
1274
  {$EXTERNALSYM TF_WRITE_BEHIND}
 
1275
 
 
1276
function TransmitFile(hSocket: TSocket; hFile: HANDLE; nNumberOfBytesToWrite: DWORD;
 
1277
  nNumberOfBytesPerSend: DWORD; lpOverlapped: LPOVERLAPPED;
 
1278
  lpTransmitBuffers: LPTRANSMIT_FILE_BUFFERS; dwReserved: DWORD): BOOL; stdcall;
 
1279
{$EXTERNALSYM TransmitFile}
 
1280
function AcceptEx(sListenSocket, sAcceptSocket: TSocket;
 
1281
  lpOutputBuffer: LPVOID; dwReceiveDataLength, dwLocalAddressLength,
 
1282
  dwRemoteAddressLength: DWORD; var lpdwBytesReceived: DWORD;
 
1283
  lpOverlapped: LPOVERLAPPED): BOOL; stdcall;
 
1284
{$EXTERNALSYM AcceptEx}
 
1285
procedure GetAcceptExSockaddrs(lpOutputBuffer: Pointer;
 
1286
  dwReceiveDataLength, dwLocalAddressLength, dwRemoteAddressLength: DWORD;
 
1287
  out LocalSockaddr: PSockAddr; var LocalSockaddrLength: Integer;
 
1288
  out RemoteSockaddr: PSockAddr; var RemoteSockaddrLength: Integer); stdcall;
 
1289
{$EXTERNALSYM GetAcceptExSockaddrs}
 
1290
 
 
1291
(* Microsoft Windows Extended data types *)
 
1292
 
 
1293
type
 
1294
  PSOCKADDR_IN = ^sockaddr_in;
 
1295
  {$EXTERNALSYM PSOCKADDR_IN}
 
1296
  LPSOCKADDR_IN = ^sockaddr_in;
 
1297
  {$EXTERNALSYM LPSOCKADDR_IN}
 
1298
  LPLINGER = PLINGER;
 
1299
  {$EXTERNALSYM LPLINGER}
 
1300
  PIN_ADDR = ^in_addr;
 
1301
  {$EXTERNALSYM PIN_ADDR}
 
1302
  LPIN_ADDR = ^in_addr;
 
1303
  {$EXTERNALSYM LPIN_ADDR}
 
1304
  PFD_SET = ^fd_set;
 
1305
  {$EXTERNALSYM PFD_SET}
 
1306
  LPFD_SET = ^fd_set;
 
1307
  {$EXTERNALSYM LPFD_SET}
 
1308
  LPHOSTENT = PHOSTENT;
 
1309
  {$EXTERNALSYM LPHOSTENT}
 
1310
  LPSERVENT = PSERVENT;
 
1311
  {$EXTERNALSYM LPSERVENT}
 
1312
  LPPROTOENT = PPROTOENT;
 
1313
  {$EXTERNALSYM LPPROTOENT}
 
1314
  LPTIMEVAL = PTIMEVAL;
 
1315
  {$EXTERNALSYM LPTIMEVAL}
 
1316
 
 
1317
(*
 
1318
 * Windows message parameter composition and decomposition
 
1319
 * macros.
 
1320
 *
 
1321
 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
 
1322
 * when constructing the response to a WSAAsyncGetXByY() routine.
 
1323
 *)
 
1324
 
 
1325
function WSAMAKEASYNCREPLY(buflen, error: WORD): DWORD;
 
1326
{$EXTERNALSYM WSAMAKEASYNCREPLY}
 
1327
 
 
1328
(*
 
1329
 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
 
1330
 * when constructing the response to WSAAsyncSelect().
 
1331
 *)
 
1332
 
 
1333
function WSAMAKESELECTREPLY(event, error: WORD): DWORD;
 
1334
{$EXTERNALSYM WSAMAKESELECTREPLY}
 
1335
 
 
1336
(*
 
1337
 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
 
1338
 * to extract the buffer length from the lParam in the response
 
1339
 * to a WSAGetXByY().
 
1340
 *)
 
1341
 
 
1342
function WSAGETASYNCBUFLEN(lParam: DWORD): WORD;
 
1343
{$EXTERNALSYM WSAGETASYNCBUFLEN}
 
1344
 
 
1345
(*
 
1346
 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
 
1347
 * to extract the error code from the lParam in the response
 
1348
 * to a WSAGetXByY().
 
1349
 *)
 
1350
 
 
1351
function WSAGETASYNCERROR(lParam: DWORD): WORD;
 
1352
{$EXTERNALSYM WSAGETASYNCERROR}
 
1353
 
 
1354
(*
 
1355
 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
 
1356
 * to extract the event code from the lParam in the response
 
1357
 * to a WSAAsyncSelect().
 
1358
 *)
 
1359
 
 
1360
function WSAGETSELECTEVENT(lParam: DWORD): WORD;
 
1361
{$EXTERNALSYM WSAGETSELECTEVENT}
 
1362
 
 
1363
(*
 
1364
 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
 
1365
 * to extract the error code from the lParam in the response
 
1366
 * to a WSAAsyncSelect().
 
1367
 *)
 
1368
 
 
1369
function WSAGETSELECTERROR(lParam: DWORD): WORD;
 
1370
{$EXTERNALSYM WSAGETSELECTERROR}
 
1371
 
 
1372
implementation
 
1373
 
 
1374
const
 
1375
  wsock32 = 'wsock32.dll';
 
1376
 
 
1377
procedure FD_CLR(fd: TSocket; var fdset: TFdSet);
 
1378
var
 
1379
  I: Cardinal;
 
1380
begin
 
1381
  I := 0;
 
1382
  while I < fdset.fd_count do
 
1383
  begin
 
1384
    if fdset.fd_array[I] = fd then
 
1385
    begin
 
1386
      while I < fdset.fd_count - 1 do
 
1387
      begin
 
1388
        fdset.fd_array[I] := fdset.fd_array[I + 1];
 
1389
        Inc(I);
 
1390
      end;
 
1391
      fdset.fd_count := fdset.fd_count - 1;
 
1392
      Break;
 
1393
    end;
 
1394
    Inc(I);
 
1395
  end;
 
1396
end;
 
1397
 
 
1398
procedure _FD_SET(fd: TSocket; var fdset: TFDSet);
 
1399
var
 
1400
  I: Cardinal;
 
1401
begin
 
1402
  I := 0;
 
1403
  while I < fdset.fd_count do
 
1404
  begin
 
1405
    if fdset.fd_array[I] = fd then
 
1406
      Break;
 
1407
    Inc(I);
 
1408
  end;
 
1409
  if I = fdset.fd_count then
 
1410
  begin
 
1411
    if fdset.fd_count < FD_SETSIZE then
 
1412
    begin
 
1413
      fdset.fd_array[I] := fd;
 
1414
      fdset.fd_count := fdset.fd_count + 1;
 
1415
    end;
 
1416
  end;
 
1417
end;
 
1418
 
 
1419
procedure FD_ZERO(var fdset: TFdSet);
 
1420
begin
 
1421
  fdset.fd_count := 0;
 
1422
end;
 
1423
 
 
1424
function FD_ISSET(fd: TSocket; var fdset: TFdSet): Boolean;
 
1425
begin
 
1426
  Result := __WSAFDIsSet(fd, fdset) <> 0;
 
1427
end;
 
1428
 
 
1429
function timerisset(const tvp: TTimeVal): Boolean;
 
1430
begin
 
1431
  Result := (tvp.tv_sec <> 0) or (tvp.tv_usec <> 0);
 
1432
end;
 
1433
 
 
1434
procedure timerclear(var tvp: TTimeVal);
 
1435
begin
 
1436
  tvp.tv_sec := 0;
 
1437
  tvp.tv_usec := 0;
 
1438
end;
 
1439
 
 
1440
function _IO(x, y: DWORD): DWORD;
 
1441
begin
 
1442
  Result := IOC_VOID or (x shl 8) or y;
 
1443
end;
 
1444
 
 
1445
function _IOR(x, y, t: DWORD): DWORD;
 
1446
begin
 
1447
  Result := IOC_OUT or ((T and IOCPARM_MASK) shl 16) or (x shl 8) or y;
 
1448
end;
 
1449
 
 
1450
function _IOW(x, y, t: DWORD): DWORD;
 
1451
begin
 
1452
  Result := DWORD(IOC_IN or ((T and IOCPARM_MASK) shl 16) or (x shl 8) or y);
 
1453
end;
 
1454
 
 
1455
function IN_CLASSA(i: DWORD): Boolean;
 
1456
begin
 
1457
  Result := i and DWORD($80000000) = 0;
 
1458
end;
 
1459
 
 
1460
function IN_CLASSB(i: DWORD): Boolean;
 
1461
begin
 
1462
  Result := i and DWORD($C0000000) = DWORD($80000000);
 
1463
end;
 
1464
 
 
1465
function IN_CLASSC(i: DWORD): Boolean;
 
1466
begin
 
1467
  Result := (i and DWORD($e0000000)) = DWORD($C0000000);
 
1468
end;
 
1469
 
 
1470
function h_errno: Integer;
 
1471
begin
 
1472
  Result := WSAGetLastError;
 
1473
end;
 
1474
 
 
1475
function WSAMAKEASYNCREPLY(buflen, error: WORD): DWORD;
 
1476
begin
 
1477
  Result := MAKELONG(buflen, error);
 
1478
end;
 
1479
 
 
1480
function WSAMAKESELECTREPLY(event, error: WORD): DWORD;
 
1481
begin
 
1482
  Result := MAKELONG(event, error);
 
1483
end;
 
1484
 
 
1485
function WSAGETASYNCBUFLEN(lParam: DWORD): WORD;
 
1486
begin
 
1487
  Result := LOWORD(lParam);
 
1488
end;
 
1489
 
 
1490
function WSAGETASYNCERROR(lParam: DWORD): WORD;
 
1491
begin
 
1492
  Result := HIWORD(lParam);
 
1493
end;
 
1494
 
 
1495
function WSAGETSELECTEVENT(lParam: DWORD): WORD;
 
1496
begin
 
1497
  Result := LOWORD(lParam);
 
1498
end;
 
1499
 
 
1500
function WSAGETSELECTERROR(lParam: DWORD): WORD;
 
1501
begin
 
1502
  Result := HIWORD(lParam);
 
1503
end;
 
1504
 
 
1505
{$IFDEF DYNAMIC_LINK}
 
1506
 
 
1507
var
 
1508
  ___WSAFDIsSet: Pointer;
 
1509
 
 
1510
function __WSAFDIsSet;
 
1511
begin
 
1512
  GetProcedureAddress(___WSAFDIsSet, wsock32, '__WSAFDIsSet');
 
1513
  asm
 
1514
        MOV     ESP, EBP
 
1515
        POP     EBP
 
1516
        JMP     [___WSAFDIsSet]
 
1517
  end;
 
1518
end;
 
1519
 
 
1520
var
 
1521
  _accept: Pointer;
 
1522
 
 
1523
function accept;
 
1524
begin
 
1525
  GetProcedureAddress(_accept, wsock32, 'accept');
 
1526
  asm
 
1527
        MOV     ESP, EBP
 
1528
        POP     EBP
 
1529
        JMP     [_accept]
 
1530
  end;
 
1531
end;
 
1532
 
 
1533
var
 
1534
  _bind: Pointer;
 
1535
 
 
1536
function bind;
 
1537
begin
 
1538
  GetProcedureAddress(_bind, wsock32, 'bind');
 
1539
  asm
 
1540
        MOV     ESP, EBP
 
1541
        POP     EBP
 
1542
        JMP     [_bind]
 
1543
  end;
 
1544
end;
 
1545
 
 
1546
var
 
1547
  _closesocket: Pointer;
 
1548
 
 
1549
function closesocket;
 
1550
begin
 
1551
  GetProcedureAddress(_closesocket, wsock32, 'closesocket');
 
1552
  asm
 
1553
        MOV     ESP, EBP
 
1554
        POP     EBP
 
1555
        JMP     [_closesocket]
 
1556
  end;
 
1557
end;
 
1558
 
 
1559
var
 
1560
  _connect: Pointer;
 
1561
 
 
1562
function connect;
 
1563
begin
 
1564
  GetProcedureAddress(_connect, wsock32, 'connect');
 
1565
  asm
 
1566
        MOV     ESP, EBP
 
1567
        POP     EBP
 
1568
        JMP     [_connect]
 
1569
  end;
 
1570
end;
 
1571
 
 
1572
var
 
1573
  _ioctlsocket: Pointer;
 
1574
 
 
1575
function ioctlsocket;
 
1576
begin
 
1577
  GetProcedureAddress(_ioctlsocket, wsock32, 'ioctlsocket');
 
1578
  asm
 
1579
        MOV     ESP, EBP
 
1580
        POP     EBP
 
1581
        JMP     [_ioctlsocket]
 
1582
  end;
 
1583
end;
 
1584
 
 
1585
var
 
1586
  _getpeername: Pointer;
 
1587
 
 
1588
function getpeername;
 
1589
begin
 
1590
  GetProcedureAddress(_getpeername, wsock32, 'getpeername');
 
1591
  asm
 
1592
        MOV     ESP, EBP
 
1593
        POP     EBP
 
1594
        JMP     [_getpeername]
 
1595
  end;
 
1596
end;
 
1597
 
 
1598
var
 
1599
  _getsockname: Pointer;
 
1600
 
 
1601
function getsockname;
 
1602
begin
 
1603
  GetProcedureAddress(_getsockname, wsock32, 'getsockname');
 
1604
  asm
 
1605
        MOV     ESP, EBP
 
1606
        POP     EBP
 
1607
        JMP     [_getsockname]
 
1608
  end;
 
1609
end;
 
1610
 
 
1611
var
 
1612
  _getsockopt: Pointer;
 
1613
 
 
1614
function getsockopt;
 
1615
begin
 
1616
  GetProcedureAddress(_getsockopt, wsock32, 'getsockopt');
 
1617
  asm
 
1618
        MOV     ESP, EBP
 
1619
        POP     EBP
 
1620
        JMP     [_getsockopt]
 
1621
  end;
 
1622
end;
 
1623
 
 
1624
var
 
1625
  _htonl: Pointer;
 
1626
 
 
1627
function htonl;
 
1628
begin
 
1629
  GetProcedureAddress(_htonl, wsock32, 'htonl');
 
1630
  asm
 
1631
        MOV     ESP, EBP
 
1632
        POP     EBP
 
1633
        JMP     [_htonl]
 
1634
  end;
 
1635
end;
 
1636
 
 
1637
var
 
1638
  _htons: Pointer;
 
1639
 
 
1640
function htons;
 
1641
begin
 
1642
  GetProcedureAddress(_htons, wsock32, 'htons');
 
1643
  asm
 
1644
        MOV     ESP, EBP
 
1645
        POP     EBP
 
1646
        JMP     [_htons]
 
1647
  end;
 
1648
end;
 
1649
 
 
1650
var
 
1651
  _inet_addr: Pointer;
 
1652
 
 
1653
function inet_addr;
 
1654
begin
 
1655
  GetProcedureAddress(_inet_addr, wsock32, 'inet_addr');
 
1656
  asm
 
1657
        MOV     ESP, EBP
 
1658
        POP     EBP
 
1659
        JMP     [_inet_addr]
 
1660
  end;
 
1661
end;
 
1662
 
 
1663
var
 
1664
  _inet_ntoa: Pointer;
 
1665
 
 
1666
function inet_ntoa;
 
1667
begin
 
1668
  GetProcedureAddress(_inet_ntoa, wsock32, 'inet_ntoa');
 
1669
  asm
 
1670
        MOV     ESP, EBP
 
1671
        POP     EBP
 
1672
        JMP     [_inet_ntoa]
 
1673
  end;
 
1674
end;
 
1675
 
 
1676
var
 
1677
  _listen: Pointer;
 
1678
 
 
1679
function listen;
 
1680
begin
 
1681
  GetProcedureAddress(_listen, wsock32, 'listen');
 
1682
  asm
 
1683
        MOV     ESP, EBP
 
1684
        POP     EBP
 
1685
        JMP     [_listen]
 
1686
  end;
 
1687
end;
 
1688
 
 
1689
var
 
1690
  _ntohl: Pointer;
 
1691
 
 
1692
function ntohl;
 
1693
begin
 
1694
  GetProcedureAddress(_ntohl, wsock32, 'ntohl');
 
1695
  asm
 
1696
        MOV     ESP, EBP
 
1697
        POP     EBP
 
1698
        JMP     [_ntohl]
 
1699
  end;
 
1700
end;
 
1701
 
 
1702
var
 
1703
  _ntohs: Pointer;
 
1704
 
 
1705
function ntohs;
 
1706
begin
 
1707
  GetProcedureAddress(_ntohs, wsock32, 'ntohs');
 
1708
  asm
 
1709
        MOV     ESP, EBP
 
1710
        POP     EBP
 
1711
        JMP     [_ntohs]
 
1712
  end;
 
1713
end;
 
1714
 
 
1715
var
 
1716
  _recv: Pointer;
 
1717
 
 
1718
function recv;
 
1719
begin
 
1720
  GetProcedureAddress(_recv, wsock32, 'recv');
 
1721
  asm
 
1722
        MOV     ESP, EBP
 
1723
        POP     EBP
 
1724
        JMP     [_recv]
 
1725
  end;
 
1726
end;
 
1727
 
 
1728
var
 
1729
  _recvfrom: Pointer;
 
1730
 
 
1731
function recvfrom;
 
1732
begin
 
1733
  GetProcedureAddress(_recvfrom, wsock32, 'recvfrom');
 
1734
  asm
 
1735
        MOV     ESP, EBP
 
1736
        POP     EBP
 
1737
        JMP     [_recvfrom]
 
1738
  end;
 
1739
end;
 
1740
 
 
1741
var
 
1742
  _select: Pointer;
 
1743
 
 
1744
function select;
 
1745
begin
 
1746
  GetProcedureAddress(_select, wsock32, 'select');
 
1747
  asm
 
1748
        MOV     ESP, EBP
 
1749
        POP     EBP
 
1750
        JMP     [_select]
 
1751
  end;
 
1752
end;
 
1753
 
 
1754
var
 
1755
  _send: Pointer;
 
1756
 
 
1757
function send;
 
1758
begin
 
1759
  GetProcedureAddress(_send, wsock32, 'send');
 
1760
  asm
 
1761
        MOV     ESP, EBP
 
1762
        POP     EBP
 
1763
        JMP     [_send]
 
1764
  end;
 
1765
end;
 
1766
 
 
1767
var
 
1768
  _sendto: Pointer;
 
1769
 
 
1770
function sendto;
 
1771
begin
 
1772
  GetProcedureAddress(_sendto, wsock32, 'sendto');
 
1773
  asm
 
1774
        MOV     ESP, EBP
 
1775
        POP     EBP
 
1776
        JMP     [_sendto]
 
1777
  end;
 
1778
end;
 
1779
 
 
1780
var
 
1781
  _setsockopt: Pointer;
 
1782
 
 
1783
function setsockopt;
 
1784
begin
 
1785
  GetProcedureAddress(_setsockopt, wsock32, 'setsockopt');
 
1786
  asm
 
1787
        MOV     ESP, EBP
 
1788
        POP     EBP
 
1789
        JMP     [_setsockopt]
 
1790
  end;
 
1791
end;
 
1792
 
 
1793
var
 
1794
  _shutdown: Pointer;
 
1795
 
 
1796
function shutdown;
 
1797
begin
 
1798
  GetProcedureAddress(_shutdown, wsock32, 'shutdown');
 
1799
  asm
 
1800
        MOV     ESP, EBP
 
1801
        POP     EBP
 
1802
        JMP     [_shutdown]
 
1803
  end;
 
1804
end;
 
1805
 
 
1806
var
 
1807
  _socket: Pointer;
 
1808
 
 
1809
function socket;
 
1810
begin
 
1811
  GetProcedureAddress(_socket, wsock32, 'socket');
 
1812
  asm
 
1813
        MOV     ESP, EBP
 
1814
        POP     EBP
 
1815
        JMP     [_socket]
 
1816
  end;
 
1817
end;
 
1818
 
 
1819
var
 
1820
  _gethostbyaddr: Pointer;
 
1821
 
 
1822
function gethostbyaddr;
 
1823
begin
 
1824
  GetProcedureAddress(_gethostbyaddr, wsock32, 'gethostbyaddr');
 
1825
  asm
 
1826
        MOV     ESP, EBP
 
1827
        POP     EBP
 
1828
        JMP     [_gethostbyaddr]
 
1829
  end;
 
1830
end;
 
1831
 
 
1832
var
 
1833
  _gethostbyname: Pointer;
 
1834
 
 
1835
function gethostbyname;
 
1836
begin
 
1837
  GetProcedureAddress(_gethostbyname, wsock32, 'gethostbyname');
 
1838
  asm
 
1839
        MOV     ESP, EBP
 
1840
        POP     EBP
 
1841
        JMP     [_gethostbyname]
 
1842
  end;
 
1843
end;
 
1844
 
 
1845
var
 
1846
  _gethostname: Pointer;
 
1847
 
 
1848
function gethostname;
 
1849
begin
 
1850
  GetProcedureAddress(_gethostname, wsock32, 'gethostname');
 
1851
  asm
 
1852
        MOV     ESP, EBP
 
1853
        POP     EBP
 
1854
        JMP     [_gethostname]
 
1855
  end;
 
1856
end;
 
1857
 
 
1858
var
 
1859
  _getservbyport: Pointer;
 
1860
 
 
1861
function getservbyport;
 
1862
begin
 
1863
  GetProcedureAddress(_getservbyport, wsock32, 'getservbyport');
 
1864
  asm
 
1865
        MOV     ESP, EBP
 
1866
        POP     EBP
 
1867
        JMP     [_getservbyport]
 
1868
  end;
 
1869
end;
 
1870
 
 
1871
var
 
1872
  _getservbyname: Pointer;
 
1873
 
 
1874
function getservbyname;
 
1875
begin
 
1876
  GetProcedureAddress(_getservbyname, wsock32, 'getservbyname');
 
1877
  asm
 
1878
        MOV     ESP, EBP
 
1879
        POP     EBP
 
1880
        JMP     [_getservbyname]
 
1881
  end;
 
1882
end;
 
1883
 
 
1884
var
 
1885
  _getprotobynumber: Pointer;
 
1886
 
 
1887
function getprotobynumber;
 
1888
begin
 
1889
  GetProcedureAddress(_getprotobynumber, wsock32, 'getprotobynumber');
 
1890
  asm
 
1891
        MOV     ESP, EBP
 
1892
        POP     EBP
 
1893
        JMP     [_getprotobynumber]
 
1894
  end;
 
1895
end;
 
1896
 
 
1897
var
 
1898
  _getprotobyname: Pointer;
 
1899
 
 
1900
function getprotobyname;
 
1901
begin
 
1902
  GetProcedureAddress(_getprotobyname, wsock32, 'getprotobyname');
 
1903
  asm
 
1904
        MOV     ESP, EBP
 
1905
        POP     EBP
 
1906
        JMP     [_getprotobyname]
 
1907
  end;
 
1908
end;
 
1909
 
 
1910
var
 
1911
  _WSAStartup: Pointer;
 
1912
 
 
1913
function WSAStartup;
 
1914
begin
 
1915
  GetProcedureAddress(_WSAStartup, wsock32, 'WSAStartup');
 
1916
  asm
 
1917
        MOV     ESP, EBP
 
1918
        POP     EBP
 
1919
        JMP     [_WSAStartup]
 
1920
  end;
 
1921
end;
 
1922
 
 
1923
var
 
1924
  _WSACleanup: Pointer;
 
1925
 
 
1926
function WSACleanup;
 
1927
begin
 
1928
  GetProcedureAddress(_WSACleanup, wsock32, 'WSACleanup');
 
1929
  asm
 
1930
        MOV     ESP, EBP
 
1931
        POP     EBP
 
1932
        JMP     [_WSACleanup]
 
1933
  end;
 
1934
end;
 
1935
 
 
1936
var
 
1937
  _WSASetLastError: Pointer;
 
1938
 
 
1939
procedure WSASetLastError;
 
1940
begin
 
1941
  GetProcedureAddress(_WSASetLastError, wsock32, 'WSASetLastError');
 
1942
  asm
 
1943
        MOV     ESP, EBP
 
1944
        POP     EBP
 
1945
        JMP     [_WSASetLastError]
 
1946
  end;
 
1947
end;
 
1948
 
 
1949
var
 
1950
  _WSAGetLastError: Pointer;
 
1951
 
 
1952
function WSAGetLastError;
 
1953
begin
 
1954
  GetProcedureAddress(_WSAGetLastError, wsock32, 'WSAGetLastError');
 
1955
  asm
 
1956
        MOV     ESP, EBP
 
1957
        POP     EBP
 
1958
        JMP     [_WSAGetLastError]
 
1959
  end;
 
1960
end;
 
1961
 
 
1962
var
 
1963
  _WSAIsBlocking: Pointer;
 
1964
 
 
1965
function WSAIsBlocking;
 
1966
begin
 
1967
  GetProcedureAddress(_WSAIsBlocking, wsock32, 'WSAIsBlocking');
 
1968
  asm
 
1969
        MOV     ESP, EBP
 
1970
        POP     EBP
 
1971
        JMP     [_WSAIsBlocking]
 
1972
  end;
 
1973
end;
 
1974
 
 
1975
var
 
1976
  _WSAUnhookBlockingHook: Pointer;
 
1977
 
 
1978
function WSAUnhookBlockingHook;
 
1979
begin
 
1980
  GetProcedureAddress(_WSAUnhookBlockingHook, wsock32, 'WSAUnhookBlockingHook');
 
1981
  asm
 
1982
        MOV     ESP, EBP
 
1983
        POP     EBP
 
1984
        JMP     [_WSAUnhookBlockingHook]
 
1985
  end;
 
1986
end;
 
1987
 
 
1988
var
 
1989
  _WSASetBlockingHook: Pointer;
 
1990
 
 
1991
function WSASetBlockingHook;
 
1992
begin
 
1993
  GetProcedureAddress(_WSASetBlockingHook, wsock32, 'WSASetBlockingHook');
 
1994
  asm
 
1995
        MOV     ESP, EBP
 
1996
        POP     EBP
 
1997
        JMP     [_WSASetBlockingHook]
 
1998
  end;
 
1999
end;
 
2000
 
 
2001
var
 
2002
  _WSACancelBlockingCall: Pointer;
 
2003
 
 
2004
function WSACancelBlockingCall;
 
2005
begin
 
2006
  GetProcedureAddress(_WSACancelBlockingCall, wsock32, 'WSACancelBlockingCall');
 
2007
  asm
 
2008
        MOV     ESP, EBP
 
2009
        POP     EBP
 
2010
        JMP     [_WSACancelBlockingCall]
 
2011
  end;
 
2012
end;
 
2013
 
 
2014
var
 
2015
  _WSAAsyncGetServByName: Pointer;
 
2016
 
 
2017
function WSAAsyncGetServByName;
 
2018
begin
 
2019
  GetProcedureAddress(_WSAAsyncGetServByName, wsock32, 'WSAAsyncGetServByName');
 
2020
  asm
 
2021
        MOV     ESP, EBP
 
2022
        POP     EBP
 
2023
        JMP     [_WSAAsyncGetServByName]
 
2024
  end;
 
2025
end;
 
2026
 
 
2027
var
 
2028
  _WSAAsyncGetServByPort: Pointer;
 
2029
 
 
2030
function WSAAsyncGetServByPort;
 
2031
begin
 
2032
  GetProcedureAddress(_WSAAsyncGetServByPort, wsock32, 'WSAAsyncGetServByPort');
 
2033
  asm
 
2034
        MOV     ESP, EBP
 
2035
        POP     EBP
 
2036
        JMP     [_WSAAsyncGetServByPort]
 
2037
  end;
 
2038
end;
 
2039
 
 
2040
var
 
2041
  _WSAAsyncGetProtoByName: Pointer;
 
2042
 
 
2043
function WSAAsyncGetProtoByName;
 
2044
begin
 
2045
  GetProcedureAddress(_WSAAsyncGetProtoByName, wsock32, 'WSAAsyncGetProtoByName');
 
2046
  asm
 
2047
        MOV     ESP, EBP
 
2048
        POP     EBP
 
2049
        JMP     [_WSAAsyncGetProtoByName]
 
2050
  end;
 
2051
end;
 
2052
 
 
2053
var
 
2054
  _WSAAsyncGetProtoByNumber: Pointer;
 
2055
 
 
2056
function WSAAsyncGetProtoByNumber;
 
2057
begin
 
2058
  GetProcedureAddress(_WSAAsyncGetProtoByNumber, wsock32, 'WSAAsyncGetProtoByNumber');
 
2059
  asm
 
2060
        MOV     ESP, EBP
 
2061
        POP     EBP
 
2062
        JMP     [_WSAAsyncGetProtoByNumber]
 
2063
  end;
 
2064
end;
 
2065
 
 
2066
var
 
2067
  _WSAAsyncGetHostByName: Pointer;
 
2068
 
 
2069
function WSAAsyncGetHostByName;
 
2070
begin
 
2071
  GetProcedureAddress(_WSAAsyncGetHostByName, wsock32, 'WSAAsyncGetHostByName');
 
2072
  asm
 
2073
        MOV     ESP, EBP
 
2074
        POP     EBP
 
2075
        JMP     [_WSAAsyncGetHostByName]
 
2076
  end;
 
2077
end;
 
2078
 
 
2079
var
 
2080
  _WSAAsyncGetHostByAddr: Pointer;
 
2081
 
 
2082
function WSAAsyncGetHostByAddr;
 
2083
begin
 
2084
  GetProcedureAddress(_WSAAsyncGetHostByAddr, wsock32, 'WSAAsyncGetHostByAddr');
 
2085
  asm
 
2086
        MOV     ESP, EBP
 
2087
        POP     EBP
 
2088
        JMP     [_WSAAsyncGetHostByAddr]
 
2089
  end;
 
2090
end;
 
2091
 
 
2092
var
 
2093
  _WSACancelAsyncRequest: Pointer;
 
2094
 
 
2095
function WSACancelAsyncRequest;
 
2096
begin
 
2097
  GetProcedureAddress(_WSACancelAsyncRequest, wsock32, 'WSACancelAsyncRequest');
 
2098
  asm
 
2099
        MOV     ESP, EBP
 
2100
        POP     EBP
 
2101
        JMP     [_WSACancelAsyncRequest]
 
2102
  end;
 
2103
end;
 
2104
 
 
2105
var
 
2106
  _WSAAsyncSelect: Pointer;
 
2107
 
 
2108
function WSAAsyncSelect;
 
2109
begin
 
2110
  GetProcedureAddress(_WSAAsyncSelect, wsock32, 'WSAAsyncSelect');
 
2111
  asm
 
2112
        MOV     ESP, EBP
 
2113
        POP     EBP
 
2114
        JMP     [_WSAAsyncSelect]
 
2115
  end;
 
2116
end;
 
2117
 
 
2118
var
 
2119
  _WSARecvEx: Pointer;
 
2120
 
 
2121
function WSARecvEx;
 
2122
begin
 
2123
  GetProcedureAddress(_WSARecvEx, wsock32, 'WSARecvEx');
 
2124
  asm
 
2125
        MOV     ESP, EBP
 
2126
        POP     EBP
 
2127
        JMP     [_WSARecvEx]
 
2128
  end;
 
2129
end;
 
2130
 
 
2131
var
 
2132
  _TransmitFile: Pointer;
 
2133
 
 
2134
function TransmitFile;
 
2135
begin
 
2136
  GetProcedureAddress(_TransmitFile, wsock32, 'TransmitFile');
 
2137
  asm
 
2138
        MOV     ESP, EBP
 
2139
        POP     EBP
 
2140
        JMP     [_TransmitFile]
 
2141
  end;
 
2142
end;
 
2143
 
 
2144
var
 
2145
  _AcceptEx: Pointer;
 
2146
 
 
2147
function AcceptEx;
 
2148
begin
 
2149
  GetProcedureAddress(_AcceptEx, wsock32, 'AcceptEx');
 
2150
  asm
 
2151
        MOV     ESP, EBP
 
2152
        POP     EBP
 
2153
        JMP     [_AcceptEx]
 
2154
  end;
 
2155
end;
 
2156
 
 
2157
var
 
2158
  _GetAcceptExSockaddrs: Pointer;
 
2159
 
 
2160
procedure GetAcceptExSockaddrs;
 
2161
begin
 
2162
  GetProcedureAddress(_GetAcceptExSockaddrs, wsock32, 'GetAcceptExSockaddrs');
 
2163
  asm
 
2164
        MOV     ESP, EBP
 
2165
        POP     EBP
 
2166
        JMP     [_GetAcceptExSockaddrs]
 
2167
  end;
 
2168
end;
 
2169
 
 
2170
{$ELSE}
 
2171
 
 
2172
function __WSAFDIsSet; external wsock32 name '__WSAFDIsSet';
 
2173
function accept; external wsock32 name 'accept';
 
2174
function bind; external wsock32 name 'bind';
 
2175
function closesocket; external wsock32 name 'closesocket';
 
2176
function connect; external wsock32 name 'connect';
 
2177
function ioctlsocket; external wsock32 name 'ioctlsocket';
 
2178
function getpeername; external wsock32 name 'getpeername';
 
2179
function getsockname; external wsock32 name 'getsockname';
 
2180
function getsockopt; external wsock32 name 'getsockopt';
 
2181
function htonl; external wsock32 name 'htonl';
 
2182
function htons; external wsock32 name 'htons';
 
2183
function inet_addr; external wsock32 name 'inet_addr';
 
2184
function inet_ntoa; external wsock32 name 'inet_ntoa';
 
2185
function listen; external wsock32 name 'listen';
 
2186
function ntohl; external wsock32 name 'ntohl';
 
2187
function ntohs; external wsock32 name 'ntohs';
 
2188
function recv; external wsock32 name 'recv';
 
2189
function recvfrom; external wsock32 name 'recvfrom';
 
2190
function select; external wsock32 name 'select';
 
2191
function send; external wsock32 name 'send';
 
2192
function sendto; external wsock32 name 'sendto';
 
2193
function setsockopt; external wsock32 name 'setsockopt';
 
2194
function shutdown; external wsock32 name 'shutdown';
 
2195
function socket; external wsock32 name 'socket';
 
2196
function gethostbyaddr; external wsock32 name 'gethostbyaddr';
 
2197
function gethostbyname; external wsock32 name 'gethostbyname';
 
2198
function gethostname; external wsock32 name 'gethostname';
 
2199
function getservbyport; external wsock32 name 'getservbyport';
 
2200
function getservbyname; external wsock32 name 'getservbyname';
 
2201
function getprotobynumber; external wsock32 name 'getprotobynumber';
 
2202
function getprotobyname; external wsock32 name 'getprotobyname';
 
2203
function WSAStartup; external wsock32 name 'WSAStartup';
 
2204
function WSACleanup; external wsock32 name 'WSACleanup';
 
2205
procedure WSASetLastError; external wsock32 name 'WSASetLastError';
 
2206
function WSAGetLastError; external wsock32 name 'WSAGetLastError';
 
2207
function WSAIsBlocking; external wsock32 name 'WSAIsBlocking';
 
2208
function WSAUnhookBlockingHook; external wsock32 name 'WSAUnhookBlockingHook';
 
2209
function WSASetBlockingHook; external wsock32 name 'WSASetBlockingHook';
 
2210
function WSACancelBlockingCall; external wsock32 name 'WSACancelBlockingCall';
 
2211
function WSAAsyncGetServByName; external wsock32 name 'WSAAsyncGetServByName';
 
2212
function WSAAsyncGetServByPort; external wsock32 name 'WSAAsyncGetServByPort';
 
2213
function WSAAsyncGetProtoByName; external wsock32 name 'WSAAsyncGetProtoByName';
 
2214
function WSAAsyncGetProtoByNumber; external wsock32 name 'WSAAsyncGetProtoByNumber';
 
2215
function WSAAsyncGetHostByName; external wsock32 name 'WSAAsyncGetHostByName';
 
2216
function WSAAsyncGetHostByAddr; external wsock32 name 'WSAAsyncGetHostByAddr';
 
2217
function WSACancelAsyncRequest; external wsock32 name 'WSACancelAsyncRequest';
 
2218
function WSAAsyncSelect; external wsock32 name 'WSAAsyncSelect';
 
2219
function WSARecvEx; external wsock32 name 'WSARecvEx';
 
2220
function TransmitFile; external wsock32 name 'TransmitFile';
 
2221
function AcceptEx; external wsock32 name 'AcceptEx';
 
2222
procedure GetAcceptExSockaddrs; external wsock32 name 'GetAcceptExSockaddrs';
 
2223
 
 
2224
{$ENDIF DYNAMIC_LINK}
 
2225
 
 
2226
end.