winsock.pp 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. This unit contains the declarations for the WinSock2
  5. Socket Library for Netware and Win32
  6. Copyright (c) 1999-2003 by the Free Pascal development team
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************
  13. For NetWare 4.11 you must install winsock-support (i.e. nw4wsock.exe)
  14. NetWare >= 5.0 contains winsock support by default
  15. **********************************************************************}
  16. {$PACKRECORDS 1}
  17. {$R-}
  18. unit winsock;
  19. { ifndef VER0_99_14}
  20. { ifndef NO_SMART_LINK}
  21. { define support_smartlink}
  22. { endif}
  23. { endif}
  24. { ifdef support_smartlink}
  25. { smartlink on}
  26. { endif}
  27. {$smartlink off} {for now, there seems to be a problem with fpc or the linker !}
  28. {$mode objfpc}
  29. interface
  30. const
  31. {
  32. Default maximium number of sockets.
  33. this does not
  34. mean that the underlying Windows Sockets implementation has to
  35. support that many!
  36. }
  37. FD_SETSIZE = 64;
  38. type
  39. tOS_INT = LongInt;
  40. tOS_UINT = DWord;
  41. ptOS_INT = ^tOS_INT;
  42. ptOS_UINT = ^tOS_UINT;
  43. u_char = char;
  44. u_short = word;
  45. u_int = tOS_UINT;
  46. u_long = dword;
  47. pu_long = ^u_long;
  48. pu_short = ^u_short;
  49. plongint = ^longint;
  50. TSocket = u_long;
  51. BOOL = boolean;
  52. LPINT = ^integer;
  53. LPDWORD = ^dword;
  54. {$ifdef netware}
  55. OVERLAPPED = record
  56. Internal : DWORD;
  57. InternalHigh: DWORD;
  58. Offset : DWORD;
  59. OffsetHigh : DWORD;
  60. hEvent : THandle;
  61. end;
  62. LPOVERLAPPED = ^OVERLAPPED;
  63. TOVERLAPPED = OVERLAPPED;
  64. POVERLAPPED = ^OVERLAPPED;
  65. {$endif}
  66. PHandle = ^THandle;
  67. TWSAOVERLAPPED= OVERLAPPED;
  68. PWSAOVERLAPPED= ^OVERLAPPED;
  69. TWSAEVENT = THandle;
  70. PWSAEVENT = ^THandle;
  71. { there is already a procedure called FD_SET, so this
  72. record was renamed (FK) }
  73. fdset = record
  74. fd_count : u_int;
  75. fd_array : array[0..(FD_SETSIZE)-1] of TSocket;
  76. end;
  77. TFDSet = fdset;
  78. PFDSet = ^fdset;
  79. timeval = record
  80. tv_sec : longint;
  81. tv_usec : longint;
  82. end;
  83. TTimeVal = timeval;
  84. PTimeVal = ^TTimeVal;
  85. { found no reference to this type in c header files and here. AlexS }
  86. { minutes west of Greenwich }
  87. { type of dst correction }
  88. timezone = record
  89. tz_minuteswest : longint;
  90. tz_dsttime : longint;
  91. end;
  92. TTimeZone = timezone;
  93. PTimeZone = ^TTimeZone;
  94. const
  95. IOCPARM_MASK = $7f;
  96. IOC_VOID = $20000000;
  97. IOC_OUT = $40000000;
  98. IOC_IN = $80000000;
  99. IOC_INOUT = IOC_IN or IOC_OUT;
  100. FIONREAD = IOC_OUT or
  101. ((4 and IOCPARM_MASK) shl 16) or
  102. (102 shl 8) or 127;
  103. FIONBIO = IOC_IN or
  104. ((4 and IOCPARM_MASK) shl 16) or
  105. (102 shl 8) or 126;
  106. FIOASYNC = IOC_IN or
  107. ((4 and IOCPARM_MASK) shl 16) or
  108. (102 shl 8) or 125;
  109. {
  110. Structures returned by network data base library, taken from the
  111. BSD file netdb.h. All addresses are supplied in host order, and
  112. returned in network order (suitable for use in system calls).
  113. Slight modifications for differences between Linux and winsock.h
  114. }
  115. type
  116. hostent = record
  117. { official name of host }
  118. h_name: pchar;
  119. { alias list }
  120. h_aliases: ^pchar;
  121. { host address type }
  122. h_addrtype: SmallInt;
  123. { length of address }
  124. h_length: SmallInt;
  125. { list of addresses }
  126. case byte of
  127. 0: (h_addr_list: ^pchar);
  128. 1: (h_addr: ^pchar)
  129. end;
  130. THostEnt = hostent;
  131. PHostEnt = ^THostEnt;
  132. {
  133. Assumption here is that a network number
  134. fits in an unsigned long -- someday that won't be true!
  135. }
  136. netent = record
  137. { official name of net }
  138. n_name : ^char;
  139. { alias list }
  140. n_aliases : ^pchar;
  141. { net address type }
  142. n_addrtype : SmallInt;
  143. n_pad1 : SmallInt; { ensure right packaging }
  144. { network # }
  145. n_net : u_long;
  146. end;
  147. TNetEnt = netent;
  148. PNetEnt = ^TNetEnt;
  149. servent = record
  150. { official service name }
  151. s_name : ^char;
  152. { alias list }
  153. s_aliases : ^pchar;
  154. { port # }
  155. s_port : SmallInt;
  156. n_pad1 : SmallInt; { ensure right packaging }
  157. { protocol to use }
  158. s_proto : ^char;
  159. end;
  160. TServEnt = servent;
  161. PServEnt = ^TServEnt;
  162. protoent = record
  163. { official protocol name }
  164. p_name : ^char;
  165. { alias list }
  166. p_aliases : ^pchar;
  167. { protocol # }
  168. p_proto : SmallInt;
  169. p_pad1 : SmallInt; { ensure packaging }
  170. end;
  171. TProtoEnt = protoent;
  172. PProtoEnt = ^TProtoEnt;
  173. const
  174. {
  175. Standard well-known IP protocols.
  176. For some reason there are differences between Linx and winsock.h
  177. }
  178. IPPROTO_IP = 0;
  179. IPPROTO_ICMP = 1;
  180. IPPROTO_IGMP = 2;
  181. IPPROTO_GGP = 3;
  182. IPPROTO_TCP = 6;
  183. IPPORT_ECHO = 7;
  184. IPPORT_DISCARD = 9;
  185. IPPORT_SYSTAT = 11;
  186. IPPROTO_PUP = 12;
  187. IPPORT_DAYTIME = 13;
  188. IPPORT_NETSTAT = 15;
  189. IPPROTO_UDP = 17;
  190. IPPROTO_IDP = 22;
  191. IPPROTO_ND = 77;
  192. IPPROTO_RAW = 255;
  193. IPPROTO_MAX = 256;
  194. IPPORT_FTP = 21;
  195. IPPORT_TELNET = 23;
  196. IPPORT_SMTP = 25;
  197. IPPORT_TIMESERVER = 37;
  198. IPPORT_NAMESERVER = 42;
  199. IPPORT_WHOIS = 43;
  200. IPPORT_MTP = 57;
  201. IPPORT_TFTP = 69;
  202. IPPORT_RJE = 77;
  203. IPPORT_FINGER = 79;
  204. IPPORT_TTYLINK = 87;
  205. IPPORT_SUPDUP = 95;
  206. IPPORT_EXECSERVER = 512;
  207. IPPORT_LOGINSERVER = 513;
  208. IPPORT_CMDSERVER = 514;
  209. IPPORT_EFSSERVER = 520;
  210. IPPORT_BIFFUDP = 512;
  211. IPPORT_WHOSERVER = 513;
  212. IPPORT_ROUTESERVER = 520;
  213. IPPORT_RESERVED = 1024;
  214. const
  215. IMPLINK_IP = 155;
  216. IMPLINK_LOWEXPER = 156;
  217. IMPLINK_HIGHEXPER = 158;
  218. type
  219. SunB = packed record
  220. s_b1,s_b2,s_b3,s_b4 : u_char;
  221. end;
  222. SunW = packed record
  223. s_w1,s_w2 : u_short;
  224. end;
  225. in_addr = record
  226. case integer of
  227. 0 : (S_un_b : SunB);
  228. 1 : (S_un_w : SunW);
  229. 2 : (S_addr : u_long);
  230. end;
  231. TInAddr = in_addr;
  232. PInAddr = ^TInAddr;
  233. sockaddr_in = record
  234. case integer of
  235. 0 : ( (* equals to sockaddr_in, size is 16 byte *)
  236. sin_family : SmallInt; (* 2 byte *)
  237. sin_port : u_short; (* 2 byte *)
  238. sin_addr : TInAddr; (* 4 byte *)
  239. sin_zero : array[0..7] of char; (* 8 byte *)
  240. );
  241. 1 : ( (* equals to sockaddr, size is 16 byte *)
  242. sa_family : SmallInt; (* 2 byte *)
  243. sa_data : array[0..13] of char; (* 14 byte *)
  244. );
  245. end;
  246. TSockAddrIn = sockaddr_in;
  247. PSockAddrIn = ^TSockAddrIn;
  248. TSockAddr = sockaddr_in;
  249. PSockAddr = ^TSockAddr;
  250. const
  251. INADDR_ANY = $00000000;
  252. INADDR_LOOPBACK = $7F000001;
  253. INADDR_BROADCAST = $FFFFFFFF;
  254. IN_CLASSA_NET = $ff000000;
  255. IN_CLASSA_NSHIFT = 24;
  256. IN_CLASSA_HOST = $00ffffff;
  257. IN_CLASSA_MAX = 128;
  258. IN_CLASSB_NET = $ffff0000;
  259. IN_CLASSB_NSHIFT = 16;
  260. IN_CLASSB_HOST = $0000ffff;
  261. IN_CLASSB_MAX = 65536;
  262. IN_CLASSC_NET = $ffffff00;
  263. IN_CLASSC_NSHIFT = 8;
  264. IN_CLASSC_HOST = $000000ff;
  265. INADDR_NONE = $ffffffff;
  266. WSADESCRIPTION_LEN = 256;
  267. WSASYS_STATUS_LEN = 128;
  268. type
  269. WSADATA = record
  270. wVersion : WORD; { 2 byte, ofs 0 }
  271. wHighVersion : WORD; { 2 byte, ofs 2 }
  272. szDescription : array[0..(WSADESCRIPTION_LEN+1)-1] of char; { 257 byte, ofs 4 }
  273. szSystemStatus : array[0..(WSASYS_STATUS_LEN+1)-1] of char; { 129 byte, ofs 261 }
  274. iMaxSockets : word; { 2 byte, ofs 390 }
  275. iMaxUdpDg : word; { 2 byte, ofs 392 }
  276. pad1 : SmallInt; { 2 byte, ofs 394 } { ensure right packaging }
  277. lpVendorInfo : pchar; { 4 byte, ofs 396 }
  278. end; { total size 400 }
  279. TWSAData = WSADATA;
  280. PWSAData = TWSAData;
  281. const
  282. IP_OPTIONS = 1;
  283. IP_MULTICAST_IF = 2;
  284. IP_MULTICAST_TTL = 3;
  285. IP_MULTICAST_LOOP = 4;
  286. IP_ADD_MEMBERSHIP = 5;
  287. IP_DROP_MEMBERSHIP = 6;
  288. IP_DEFAULT_MULTICAST_TTL = 1;
  289. IP_DEFAULT_MULTICAST_LOOP = 1;
  290. IP_MAX_MEMBERSHIPS = 20;
  291. type
  292. ip_mreq = record
  293. imr_multiaddr : in_addr;
  294. imr_interface : in_addr;
  295. end;
  296. {
  297. Definitions related to sockets: types, address families, options,
  298. taken from the BSD file sys/socket.h.
  299. }
  300. const
  301. INVALID_SOCKET = u_long(not(1));
  302. SOCKET_ERROR = -1;
  303. SOCK_STREAM = 1;
  304. SOCK_DGRAM = 2;
  305. SOCK_RAW = 3;
  306. SOCK_RDM = 4;
  307. SOCK_SEQPACKET = 5;
  308. { For setsockoptions(2) }
  309. SO_DEBUG = $0001;
  310. SO_ACCEPTCONN = $0002;
  311. SO_REUSEADDR = $0004;
  312. SO_KEEPALIVE = $0008;
  313. SO_DONTROUTE = $0010;
  314. SO_BROADCAST = $0020;
  315. SO_USELOOPBACK = $0040;
  316. SO_LINGER = $0080;
  317. SO_OOBINLINE = $0100;
  318. {
  319. Additional options.
  320. }
  321. { send buffer size }
  322. SO_SNDBUF = $1001;
  323. { receive buffer size }
  324. SO_RCVBUF = $1002;
  325. { send low-water mark }
  326. SO_SNDLOWAT = $1003;
  327. { receive low-water mark }
  328. SO_RCVLOWAT = $1004;
  329. { send timeout }
  330. SO_SNDTIMEO = $1005;
  331. { receive timeout }
  332. SO_RCVTIMEO = $1006;
  333. { get error status and clear }
  334. SO_ERROR = $1007;
  335. { get socket type }
  336. SO_TYPE = $1008;
  337. { WinSock 2 extension -- new option }
  338. SO_GROUP_ID = $2001; { ID of a socket group }
  339. SO_GROUP_PRIORITY = $2002; { the relative priority within a group }
  340. SO_MAX_MSG_SIZE = $2003; { maximum message size }
  341. SO_PROTOCOL_INFOA = $2004; { WSAPROTOCOL_INFOA structure }
  342. SO_PROTOCOL_INFOW = $2005; { WSAPROTOCOL_INFOW structure }
  343. SO_PROTOCOL_INFO = SO_PROTOCOL_INFOW;
  344. PVD_CONFIG = $3001; { configuration info for service provider }
  345. {
  346. Options for connect and disconnect data and options. Used only by
  347. non-TCP/IP transports such as DECNet, OSI TP4, etc.
  348. }
  349. SO_CONNDATA = $7000;
  350. SO_CONNOPT = $7001;
  351. SO_DISCDATA = $7002;
  352. SO_DISCOPT = $7003;
  353. SO_CONNDATALEN = $7004;
  354. SO_CONNOPTLEN = $7005;
  355. SO_DISCDATALEN = $7006;
  356. SO_DISCOPTLEN = $7007;
  357. {
  358. Option for opening sockets for synchronous access.
  359. }
  360. SO_OPENTYPE = $7008;
  361. SO_SYNCHRONOUS_ALERT = $10;
  362. SO_SYNCHRONOUS_NONALERT = $20;
  363. {
  364. Other NT-specific options.
  365. }
  366. SO_MAXDG = $7009;
  367. SO_MAXPATHDG = $700A;
  368. SO_UPDATE_ACCEPT_CONTEXT = $700B;
  369. SO_CONNECT_TIME = $700C;
  370. {
  371. TCP options.
  372. }
  373. TCP_NODELAY = $0001;
  374. TCP_BSDURGENT = $7000;
  375. { Address families. }
  376. { unspecified }
  377. AF_UNSPEC = 0;
  378. {
  379. * Although AF_UNSPEC is defined for backwards compatibility, using
  380. * AF_UNSPEC for the "af" parameter when creating a socket is STRONGLY
  381. * DISCOURAGED. The interpretation of the "protocol" parameter
  382. * depends on the actual address family chosen. As environments grow
  383. * to include more and more address families that use overlapping
  384. * protocol values there is more and more chance of choosing an
  385. * undesired address family when AF_UNSPEC is used. }
  386. { local to host (pipes, portals) }
  387. AF_UNIX = 1;
  388. { internetwork: UDP, TCP, etc. }
  389. AF_INET = 2;
  390. { arpanet imp addresses }
  391. AF_IMPLINK = 3;
  392. { pup protocols: e.g. BSP }
  393. AF_PUP = 4;
  394. { mit CHAOS protocols }
  395. AF_CHAOS = 5;
  396. { IPX and SPX }
  397. AF_IPX = 6;
  398. { XEROX NS protocols }
  399. AF_NS = 6;
  400. { ISO protocols }
  401. AF_ISO = 7;
  402. { OSI is ISO }
  403. AF_OSI = AF_ISO;
  404. { european computer manufacturers }
  405. AF_ECMA = 8;
  406. { datakit protocols }
  407. AF_DATAKIT = 9;
  408. { CCITT protocols, X.25 etc }
  409. AF_CCITT = 10;
  410. { IBM SNA }
  411. AF_SNA = 11;
  412. { DECnet }
  413. AF_DECnet = 12;
  414. { Direct data link interface }
  415. AF_DLI = 13;
  416. { LAT }
  417. AF_LAT = 14;
  418. { NSC Hyperchannel }
  419. AF_HYLINK = 15;
  420. { AppleTalk }
  421. AF_APPLETALK = 16;
  422. { NetBios-style addresses }
  423. AF_NETBIOS = 17;
  424. { VoiceView }
  425. AF_VOICEVIEW = 18;
  426. { FireFox }
  427. AF_FIREFOX = 19;
  428. { Somebody is using this! }
  429. AF_UNKNOWN1 = 20;
  430. { Banyan }
  431. AF_BAN = 21;
  432. AF_ATM = 22;
  433. AF_INET6 = 23;
  434. AF_CLUSTER = 24;
  435. AF_12844 = 25;
  436. AF_IRDA = 26;
  437. AF_MAX = 27;
  438. type
  439. {
  440. Structure used by kernel to pass protocol
  441. information in raw sockets.
  442. }
  443. sockproto = record
  444. sp_family : u_short;
  445. sp_protocol : u_short;
  446. end;
  447. TSockProto = sockproto;
  448. PSockProto = ^TSockProto;
  449. const
  450. {
  451. Protocol families, same as address families for now.
  452. }
  453. PF_UNSPEC = AF_UNSPEC;
  454. PF_UNIX = AF_UNIX;
  455. PF_INET = AF_INET;
  456. PF_IMPLINK = AF_IMPLINK;
  457. PF_PUP = AF_PUP;
  458. PF_CHAOS = AF_CHAOS;
  459. PF_NS = AF_NS;
  460. PF_IPX = AF_IPX;
  461. PF_ISO = AF_ISO;
  462. PF_OSI = AF_OSI;
  463. PF_ECMA = AF_ECMA;
  464. PF_DATAKIT = AF_DATAKIT;
  465. PF_CCITT = AF_CCITT;
  466. PF_SNA = AF_SNA;
  467. PF_DECnet = AF_DECnet;
  468. PF_DLI = AF_DLI;
  469. PF_LAT = AF_LAT;
  470. PF_HYLINK = AF_HYLINK;
  471. PF_APPLETALK = AF_APPLETALK;
  472. PF_VOICEVIEW = AF_VOICEVIEW;
  473. PF_FIREFOX = AF_FIREFOX;
  474. PF_UNKNOWN1 = AF_UNKNOWN1;
  475. PF_BAN = AF_BAN;
  476. PF_ATM = AF_ATM;
  477. PF_INET6 = AF_INET6;
  478. PF_MAX = AF_MAX;
  479. type
  480. {
  481. Structure used for manipulating linger option.
  482. }
  483. linger = record
  484. l_onoff : u_short;
  485. l_linger : u_short;
  486. end;
  487. TLinger = linger;
  488. PLinger = ^TLinger;
  489. const
  490. {
  491. Level number for (get/set)sockopt() to apply to socket itself.
  492. }
  493. { options for socket level }
  494. SOL_SOCKET = $ffff;
  495. {
  496. Maximum queue length specifiable by listen.
  497. }
  498. SOMAXCONN = $7fffffff;
  499. { process out-of-band data }
  500. MSG_OOB = $1;
  501. { peek at incoming message }
  502. MSG_PEEK = $2;
  503. { send without using routing tables }
  504. MSG_DONTROUTE = $4;
  505. MSG_MAXIOVLEN = 16;
  506. { partial send or recv for message xport }
  507. MSG_PARTIAL = $8000;
  508. {
  509. Define constant based on rfc883, used by gethostbyxxxx() calls.
  510. }
  511. MAXGETHOSTSTRUCT = 1024;
  512. MAXHOSTNAMELEN = MAXGETHOSTSTRUCT;
  513. { Winsock2 extension -- new flags for WSASend, WSASendTo, WSARecv
  514. and WSARecvFrom }
  515. MSG_INTERRUPT = $10; { send/recv in the interrupt context }
  516. { Define flags to be used with the WSAAsyncSelect() call. }
  517. FD_READ = $01;
  518. FD_WRITE = $02;
  519. FD_OOB = $04;
  520. FD_ACCEPT = $08;
  521. FD_CONNECT = $10;
  522. FD_CLOSE = $20;
  523. FD_QOS = $40;
  524. FD_GROUP_QOS = $80;
  525. FD_ROUTING_INTERFACE_CHANGE = $100;
  526. FD_ADDRESS_LIST_CHANGE = $200;
  527. FD_MAX_EVENTS = 10;
  528. FD_ALL_EVENTS = $4ff;
  529. { All Windows Sockets error constants are biased by WSABASEERR from
  530. the "normal" }
  531. WSABASEERR = 10000;
  532. { Windows Sockets definitions of regular Microsoft C error constants }
  533. WSAEINTR = WSABASEERR + 4;
  534. WSAEBADF = WSABASEERR + 9;
  535. WSAEACCES = WSABASEERR + 13;
  536. WSAEFAULT = WSABASEERR + 14;
  537. WSAEINVAL = WSABASEERR + 22;
  538. WSAEMFILE = WSABASEERR + 24;
  539. { Windows Sockets definitions of regular Berkeley error constants }
  540. WSAEWOULDBLOCK = WSABASEERR + 35;
  541. WSAEINPROGRESS = WSABASEERR + 36;
  542. WSAEALREADY = WSABASEERR + 37;
  543. WSAENOTSOCK = WSABASEERR + 38;
  544. WSAEDESTADDRREQ = WSABASEERR + 39;
  545. WSAEMSGSIZE = WSABASEERR + 40;
  546. WSAEPROTOTYPE = WSABASEERR + 41;
  547. WSAENOPROTOOPT = WSABASEERR + 42;
  548. WSAEPROTONOSUPPORT = WSABASEERR + 43;
  549. WSAESOCKTNOSUPPORT = WSABASEERR + 44;
  550. WSAEOPNOTSUPP = WSABASEERR + 45;
  551. WSAEPFNOSUPPORT = WSABASEERR + 46;
  552. WSAEAFNOSUPPORT = WSABASEERR + 47;
  553. WSAEADDRINUSE = WSABASEERR + 48;
  554. WSAEADDRNOTAVAIL = WSABASEERR + 49;
  555. WSAENETDOWN = WSABASEERR + 50;
  556. WSAENETUNREACH = WSABASEERR + 51;
  557. WSAENETRESET = WSABASEERR + 52;
  558. WSAECONNABORTED = WSABASEERR + 53;
  559. WSAECONNRESET = WSABASEERR + 54;
  560. WSAENOBUFS = WSABASEERR + 55;
  561. WSAEISCONN = WSABASEERR + 56;
  562. WSAENOTCONN = WSABASEERR + 57;
  563. WSAESHUTDOWN = WSABASEERR + 58;
  564. WSAETOOMANYREFS = WSABASEERR + 59;
  565. WSAETIMEDOUT = WSABASEERR + 60;
  566. WSAECONNREFUSED = WSABASEERR + 61;
  567. WSAELOOP = WSABASEERR + 62;
  568. WSAENAMETOOLONG = WSABASEERR + 63;
  569. WSAEHOSTDOWN = WSABASEERR + 64;
  570. WSAEHOSTUNREACH = WSABASEERR + 65;
  571. WSAENOTEMPTY = WSABASEERR + 66;
  572. WSAEPROCLIM = WSABASEERR + 67;
  573. WSAEUSERS = WSABASEERR + 68;
  574. WSAEDQUOT = WSABASEERR + 69;
  575. WSAESTALE = WSABASEERR + 70;
  576. WSAEREMOTE = WSABASEERR + 71;
  577. { Extended Windows Sockets error constant definitions }
  578. WSASYSNOTREADY = WSABASEERR + 91;
  579. WSAVERNOTSUPPORTED = WSABASEERR + 92;
  580. WSANOTINITIALISED = WSABASEERR + 93;
  581. WSAEDISCON = WSABASEERR + 101;
  582. WSAENOMORE = WSABASEERR+102;
  583. WSAECANCELLED = WSABASEERR+103;
  584. WSAEINVALIDPROCTABLE = WSABASEERR+104;
  585. WSAEINVALIDPROVIDER = WSABASEERR+105;
  586. WSAEPROVIDERFAILEDINIT = WSABASEERR+106;
  587. WSASYSCALLFAILURE = WSABASEERR+107;
  588. WSASERVICE_NOT_FOUND = WSABASEERR+108;
  589. WSATYPE_NOT_FOUND = WSABASEERR+109;
  590. WSA_E_NO_MORE = WSABASEERR+110;
  591. WSA_E_CANCELLED = WSABASEERR+111;
  592. WSAEREFUSED = WSABASEERR+112;
  593. {
  594. Error return codes from gethostbyname() and gethostbyaddr()
  595. (when using the resolver). Note that these errors are
  596. retrieved via WSAGetLastError() and must therefore follow
  597. the rules for avoiding clashes with error numbers from
  598. specific implementations or language run-time systems.
  599. For this reason the codes are based at WSABASEERR+1001.
  600. Note also that [WSA]NO_ADDRESS is defined only for
  601. compatibility purposes.
  602. }
  603. WSAHOST_NOT_FOUND = WSABASEERR + 1001;
  604. HOST_NOT_FOUND = WSAHOST_NOT_FOUND;
  605. { Non-Authoritative: Host not found, or SERVERFAIL }
  606. WSATRY_AGAIN = WSABASEERR + 1002;
  607. TRY_AGAIN = WSATRY_AGAIN;
  608. { Non recoverable errors, FORMERR, REFUSED, NOTIMP }
  609. WSANO_RECOVERY = WSABASEERR + 1003;
  610. NO_RECOVERY = WSANO_RECOVERY;
  611. { Valid name, no data record of requested type }
  612. WSANO_DATA = WSABASEERR + 1004;
  613. NO_DATA = WSANO_DATA;
  614. { no address, look for MX record }
  615. WSANO_ADDRESS = WSANO_DATA;
  616. NO_ADDRESS = WSANO_ADDRESS;
  617. { Define QOS related error return codes }
  618. WSA_QOS_RECEIVERS = WSABASEERR + 1005;
  619. { at least one Reserve has arrived }
  620. WSA_QOS_SENDERS = WSABASEERR + 1006;
  621. { at least one Path has arrived }
  622. WSA_QOS_NO_SENDERS = WSABASEERR + 1007;
  623. { there are no senders }
  624. WSA_QOS_NO_RECEIVERS = WSABASEERR + 1008;
  625. { there are no receivers }
  626. WSA_QOS_REQUEST_CONFIRMED = WSABASEERR + 1009;
  627. { Reserve has been confirmed }
  628. WSA_QOS_ADMISSION_FAILURE = WSABASEERR + 1010;
  629. WSA_QOS_POLICY_FAILURE = WSABASEERR + 1011;
  630. { rejected for administrative reasons - bad credentials }
  631. WSA_QOS_BAD_STYLE = WSABASEERR + 1012;
  632. { unknown or conflicting style }
  633. WSA_QOS_BAD_OBJECT = WSABASEERR + 1013;
  634. {* problem with some part of the filterspec or providerspecific
  635. * buffer in general }
  636. WSA_QOS_TRAFFIC_CTRL_ERROR = WSABASEERR + 1014;
  637. { problem with some part of the flowspec }
  638. WSA_QOS_GENERIC_ERROR = WSABASEERR + 1015;
  639. { general error }
  640. const
  641. {
  642. Windows Sockets errors redefined as regular Berkeley error constants.
  643. }
  644. EWOULDBLOCK = WSAEWOULDBLOCK;
  645. EINPROGRESS = WSAEINPROGRESS;
  646. EALREADY = WSAEALREADY;
  647. ENOTSOCK = WSAENOTSOCK;
  648. EDESTADDRREQ = WSAEDESTADDRREQ;
  649. EMSGSIZE = WSAEMSGSIZE;
  650. EPROTOTYPE = WSAEPROTOTYPE;
  651. ENOPROTOOPT = WSAENOPROTOOPT;
  652. EPROTONOSUPPORT = WSAEPROTONOSUPPORT;
  653. ESOCKTNOSUPPORT = WSAESOCKTNOSUPPORT;
  654. EOPNOTSUPP = WSAEOPNOTSUPP;
  655. EPFNOSUPPORT = WSAEPFNOSUPPORT;
  656. EAFNOSUPPORT = WSAEAFNOSUPPORT;
  657. EADDRINUSE = WSAEADDRINUSE;
  658. EADDRNOTAVAIL = WSAEADDRNOTAVAIL;
  659. ENETDOWN = WSAENETDOWN;
  660. ENETUNREACH = WSAENETUNREACH;
  661. ENETRESET = WSAENETRESET;
  662. ECONNABORTED = WSAECONNABORTED;
  663. ECONNRESET = WSAECONNRESET;
  664. ENOBUFS = WSAENOBUFS;
  665. EISCONN = WSAEISCONN;
  666. ENOTCONN = WSAENOTCONN;
  667. ESHUTDOWN = WSAESHUTDOWN;
  668. ETOOMANYREFS = WSAETOOMANYREFS;
  669. ETIMEDOUT = WSAETIMEDOUT;
  670. ECONNREFUSED = WSAECONNREFUSED;
  671. ELOOP = WSAELOOP;
  672. ENAMETOOLONG = WSAENAMETOOLONG;
  673. EHOSTDOWN = WSAEHOSTDOWN;
  674. EHOSTUNREACH = WSAEHOSTUNREACH;
  675. ENOTEMPTY = WSAENOTEMPTY;
  676. EPROCLIM = WSAEPROCLIM;
  677. EUSERS = WSAEUSERS;
  678. EDQUOT = WSAEDQUOT;
  679. ESTALE = WSAESTALE;
  680. EREMOTE = WSAEREMOTE;
  681. TF_DISCONNECT = $01;
  682. TF_REUSE_SOCKET = $02;
  683. TF_WRITE_BEHIND = $04;
  684. {
  685. Options for use with [gs]etsockopt at the IP level.
  686. }
  687. IP_TTL = 7;
  688. IP_TOS = 8;
  689. IP_DONTFRAGMENT = 9;
  690. type
  691. _TRANSMIT_FILE_BUFFERS = record
  692. Head : Pointer;
  693. HeadLength : dword;
  694. Tail : Pointer;
  695. TailLength : dword;
  696. end;
  697. TRANSMIT_FILE_BUFFERS = _TRANSMIT_FILE_BUFFERS;
  698. TTransmitFileBuffers = _TRANSMIT_FILE_BUFFERS;
  699. PTransmitFileBuffers = ^TTransmitFileBuffers;
  700. { WinSock 2 extension -- WSABUF and QOS struct, include qos.h
  701. to pull in FLOWSPEC and related definitions }
  702. { the length of the buffer }
  703. (* far ignored *)
  704. { the pointer to the buffer }
  705. (* far ignored *)
  706. TWSABUF = record
  707. len : u_long;
  708. buf : ^char;
  709. end;
  710. _WSABUF = TWSABUF;
  711. LPWSABUF = ^TWSABUF;
  712. PWSABUF = ^TWSABUF;
  713. {$i qos.inc }
  714. { the flow spec for data sending }
  715. { the flow spec for data receiving }
  716. { additional provider specific stuff }
  717. type
  718. TQualityOfService = record
  719. SendingFlowspec : TFLOWSPEC;
  720. ReceivingFlowspec : TFLOWSPEC;
  721. ProviderSpecific : TWSABUF;
  722. end;
  723. TQOS = TQualityOfService;
  724. PQOS = ^TQOS;
  725. { WinSock 2 extension -- manifest constants for return values of the condition function }
  726. const
  727. CF_ACCEPT = $0000;
  728. CF_REJECT = $0001;
  729. CF_DEFER = $0002;
  730. { WinSock 2 extension -- manifest constants for shutdown() }
  731. SD_RECEIVE = $00;
  732. SD_SEND = $01;
  733. SD_BOTH = $02;
  734. { WinSock 2 extension -- data type and manifest constants for socket groups }
  735. type
  736. TGROUP = dword;
  737. PGROUP = ^TGROUP;
  738. const
  739. SG_UNCONSTRAINED_GROUP = $01;
  740. SG_CONSTRAINED_GROUP = $02;
  741. { WinSock 2 extension -- data type for WSAEnumNetworkEvents() }
  742. type
  743. TWSANETWORKEVENTS = record
  744. lNetworkEvents : longint;
  745. iErrorCode : array[0..(FD_MAX_EVENTS)-1] of longint;
  746. end;
  747. LPWSANETWORKEVENTS = ^TWSANETWORKEVENTS;
  748. PWSANETWORKEVENTS = ^TWSANETWORKEVENTS;
  749. { WinSock 2 extension -- WSAPROTOCOL_INFO structure and associated
  750. manifest constants }
  751. type
  752. TGUID = record
  753. Data1 : dword;
  754. Data2 : word;
  755. Data3 : word;
  756. Data4 : array[0..7] of byte;
  757. end;
  758. PGUID = ^TGUID;
  759. LPGUID = PGUID;
  760. const
  761. MAX_PROTOCOL_CHAIN = 7;
  762. BASE_PROTOCOL = 1;
  763. LAYERED_PROTOCOL = 0;
  764. { the length of the chain, }
  765. { length = 0 means layered protocol, }
  766. { length = 1 means base protocol, }
  767. { length > 1 means protocol chain }
  768. { a list of dwCatalogEntryIds }
  769. type
  770. TWSAPROTOCOLCHAIN = record
  771. ChainLen : longint;
  772. ChainEntries : array[0..(MAX_PROTOCOL_CHAIN)-1] of DWORD;
  773. end;
  774. LPWSAPROTOCOLCHAIN = ^TWSAPROTOCOLCHAIN;
  775. PWSAPROTOCOLCHAIN = ^TWSAPROTOCOLCHAIN;
  776. const
  777. WSAPROTOCOL_LEN = 255;
  778. (* far ignored *)
  779. type
  780. TWSAPROTOCOL_INFOA = record
  781. dwServiceFlags1 : DWORD;
  782. dwServiceFlags2 : DWORD;
  783. dwServiceFlags3 : DWORD;
  784. dwServiceFlags4 : DWORD;
  785. dwProviderFlags : DWORD;
  786. ProviderId : TGUID;
  787. dwCatalogEntryId: DWORD;
  788. ProtocolChain : TWSAPROTOCOLCHAIN;
  789. iVersion : longint;
  790. iAddressFamily : longint;
  791. iMaxSockAddr : longint;
  792. iMinSockAddr : longint;
  793. iSocketType : longint;
  794. iProtocol : longint;
  795. iProtocolMaxOffset : longint;
  796. iNetworkByteOrder : longint;
  797. iSecurityScheme : longint;
  798. dwMessageSize : DWORD;
  799. dwProviderReserved : DWORD;
  800. szProtocol : array[0..(WSAPROTOCOL_LEN + 1)-1] of CHAR;
  801. end;
  802. LPWSAPROTOCOL_INFOA = ^TWSAPROTOCOL_INFOA;
  803. PWSAPROTOCOL_INFOA = ^TWSAPROTOCOL_INFOA;
  804. TWSAPROTOCOL_INFOW = record
  805. dwServiceFlags1 : DWORD;
  806. dwServiceFlags2 : DWORD;
  807. dwServiceFlags3 : DWORD;
  808. dwServiceFlags4 : DWORD;
  809. dwProviderFlags : DWORD;
  810. ProviderId : TGUID;
  811. dwCatalogEntryId: DWORD;
  812. ProtocolChain : TWSAPROTOCOLCHAIN;
  813. iVersion : longint;
  814. iAddressFamily : longint;
  815. iMaxSockAddr : longint;
  816. iMinSockAddr : longint;
  817. iSocketType : longint;
  818. iProtocol : longint;
  819. iProtocolMaxOffset : longint;
  820. iNetworkByteOrder : longint;
  821. iSecurityScheme : longint;
  822. dwMessageSize : DWORD;
  823. dwProviderReserved : DWORD;
  824. szProtocol : array[0..(WSAPROTOCOL_LEN + 1)-1] of WCHAR;
  825. end;
  826. LPWSAPROTOCOL_INFOW = ^TWSAPROTOCOL_INFOW;
  827. PWSAPROTOCOL_INFOW = ^TWSAPROTOCOL_INFOW;
  828. {$ifdef UNICODE}
  829. type
  830. TWSAPROTOCOL_INFO = TWSAPROTOCOL_INFOW;
  831. LPWSAPROTOCOL_INFO = LPWSAPROTOCOL_INFOW;
  832. PWSAPROTOCOL_INFO = PWSAPROTOCOL_INFOW;
  833. {$else}
  834. type
  835. TWSAPROTOCOL_INFO = TWSAPROTOCOL_INFOA;
  836. LPWSAPROTOCOL_INFO = LPWSAPROTOCOL_INFOA;
  837. PWSAPROTOCOL_INFO = PWSAPROTOCOL_INFOA;
  838. {$endif}
  839. { Flag bit definitions for dwProviderFlags }
  840. const
  841. PFL_MULTIPLE_PROTO_ENTRIES = $00000001;
  842. PFL_RECOMMENDED_PROTO_ENTRY = $00000002;
  843. PFL_HIDDEN = $00000004;
  844. PFL_MATCHES_PROTOCOL_ZERO = $00000008;
  845. { Flag bit definitions for dwServiceFlags1 }
  846. XP1_CONNECTIONLESS = $00000001;
  847. XP1_GUARANTEED_DELIVERY = $00000002;
  848. XP1_GUARANTEED_ORDER = $00000004;
  849. XP1_MESSAGE_ORIENTED = $00000008;
  850. XP1_PSEUDO_STREAM = $00000010;
  851. XP1_GRACEFUL_CLOSE = $00000020;
  852. XP1_EXPEDITED_DATA = $00000040;
  853. XP1_CONNECT_DATA = $00000080;
  854. XP1_DISCONNECT_DATA = $00000100;
  855. XP1_SUPPORT_BROADCAST = $00000200;
  856. XP1_SUPPORT_MULTIPOINT = $00000400;
  857. XP1_MULTIPOINT_CONTROL_PLANE = $00000800;
  858. XP1_MULTIPOINT_DATA_PLANE = $00001000;
  859. XP1_QOS_SUPPORTED = $00002000;
  860. XP1_INTERRUPT = $00004000;
  861. XP1_UNI_SEND = $00008000;
  862. XP1_UNI_RECV = $00010000;
  863. XP1_IFS_HANDLES = $00020000;
  864. XP1_PARTIAL_MESSAGE = $00040000;
  865. BIGENDIAN = $0000;
  866. LITTLEENDIAN = $0001;
  867. SECURITY_PROTOCOL_NONE = $0000;
  868. { WinSock 2 extension -- manifest constants for WSAJoinLeaf() }
  869. JL_SENDER_ONLY = $01;
  870. JL_RECEIVER_ONLY = $02;
  871. JL_BOTH = $04;
  872. { WinSock 2 extension -- manifest constants for WSASocket() }
  873. WSA_FLAG_OVERLAPPED = $01;
  874. WSA_FLAG_MULTIPOINT_C_ROOT = $02;
  875. WSA_FLAG_MULTIPOINT_C_LEAF = $04;
  876. WSA_FLAG_MULTIPOINT_D_ROOT = $08;
  877. WSA_FLAG_MULTIPOINT_D_LEAF = $10;
  878. { WinSock 2 extension -- manifest constants for WSAIoctl() }
  879. IOC_UNIX = $00000000;
  880. IOC_WS2 = $08000000;
  881. IOC_PROTOCOL = $10000000;
  882. IOC_VENDOR = $18000000;
  883. { WinSock 2 extension -- manifest constants for SIO_TRANSLATE_HANDLE ioctl }
  884. const
  885. TH_NETDEV = $00000001;
  886. TH_TAPI = $00000002;
  887. { Microsoft Windows Extended data types required for the functions to
  888. convert back and forth between binary and string forms of
  889. addresses. }
  890. type
  891. //PSOCKADDR = sockaddr;
  892. LPSOCKADDR = PSockAddr;
  893. { Manifest constants and type definitions related to name resolution and
  894. registration (RNR) API }
  895. type
  896. TBLOB = record
  897. cbSize : u_long;
  898. pBlobData:ARRAY[0..0] OF POINTER; {???}
  899. end;
  900. PBLOB = ^TBLOB;
  901. { Service Install Flags }
  902. const
  903. SERVICE_MULTIPLE = $00000001;
  904. { & Name Spaces }
  905. NS_ALL = 0;
  906. NS_SAP = 1;
  907. NS_NDS = 2;
  908. NS_PEER_BROWSE = 3;
  909. NS_TCPIP_LOCAL = 10;
  910. NS_TCPIP_HOSTS = 11;
  911. NS_DNS = 12;
  912. NS_NETBT = 13;
  913. NS_WINS = 14;
  914. NS_NBP = 20;
  915. NS_MS = 30;
  916. NS_STDA = 31;
  917. NS_NTDS = 32;
  918. NS_X500 = 40;
  919. NS_NIS = 41;
  920. NS_NISPLUS = 42;
  921. NS_WRQ = 50;
  922. { Resolution flags for WSAGetAddressByName().
  923. Note these are also used by the 1.1 API GetAddressByName, so
  924. leave them around. }
  925. RES_UNUSED_1 = $00000001;
  926. RES_FLUSH_CACHE = $00000002;
  927. RES_SERVICE = $00000004;
  928. { RES_SERVICE }
  929. { Well known value names for Service Types }
  930. const
  931. SERVICE_TYPE_VALUE_IPXPORTA = 'IpxSocket';
  932. (* error #define SERVICE_TYPE_VALUE_IPXPORTW L"IpxSocket" *)
  933. SERVICE_TYPE_VALUE_SAPIDA = 'SapId';
  934. (* error #define SERVICE_TYPE_VALUE_SAPIDW L"SapId" *)
  935. SERVICE_TYPE_VALUE_TCPPORTA = 'TcpPort';
  936. (* error #define SERVICE_TYPE_VALUE_TCPPORTW L"TcpPort" *)
  937. SERVICE_TYPE_VALUE_UDPPORTA = 'UdpPort';
  938. (* error #define SERVICE_TYPE_VALUE_UDPPORTW L"UdpPort" *)
  939. SERVICE_TYPE_VALUE_OBJECTIDA = 'ObjectId';
  940. (* error #define SERVICE_TYPE_VALUE_OBJECTIDW L"ObjectId" *)
  941. {$ifdef UNICODE}
  942. const
  943. SERVICE_TYPE_VALUE_SAPID = SERVICE_TYPE_VALUE_SAPIDW;
  944. SERVICE_TYPE_VALUE_TCPPORT = SERVICE_TYPE_VALUE_TCPPORTW;
  945. SERVICE_TYPE_VALUE_UDPPORT = SERVICE_TYPE_VALUE_UDPPORTW;
  946. SERVICE_TYPE_VALUE_OBJECTID = SERVICE_TYPE_VALUE_OBJECTIDW;
  947. {$else}
  948. { not UNICODE }
  949. const
  950. SERVICE_TYPE_VALUE_SAPID = SERVICE_TYPE_VALUE_SAPIDA;
  951. SERVICE_TYPE_VALUE_TCPPORT = SERVICE_TYPE_VALUE_TCPPORTA;
  952. SERVICE_TYPE_VALUE_UDPPORT = SERVICE_TYPE_VALUE_UDPPORTA;
  953. SERVICE_TYPE_VALUE_OBJECTID = SERVICE_TYPE_VALUE_OBJECTIDA;
  954. {$endif}
  955. {$ifndef __CSADDR_DEFINED__}
  956. {$define __CSADDR_DEFINED__}
  957. { SockAddr Information }
  958. type
  959. TSOCKET_ADDRESS = record
  960. lpSockaddr : PSockAddr;
  961. iSockaddrLength : tOS_INT;
  962. end;
  963. PSOCKET_ADDRESS = ^TSOCKET_ADDRESS;
  964. LPSOCKET_ADDRESS = ^TSOCKET_ADDRESS;
  965. { CSAddr Information }
  966. TCSADDR_INFO = record
  967. LocalAddr : TSOCKET_ADDRESS;
  968. RemoteAddr : TSOCKET_ADDRESS;
  969. iSocketType : tOS_INT;
  970. iProtocol : tOS_INT;
  971. end;
  972. PCSADDR_INFO = ^TCSADDR_INFO;
  973. LPCSADDR_INFO = ^TCSADDR_INFO;
  974. {$endif}
  975. { Address list returned via SIO_ADDRESS_LIST_QUERY }
  976. type
  977. TSOCKET_ADDRESS_LIST = record
  978. iAddressCount : tOS_INT;
  979. Address : array[0..0] of TSOCKET_ADDRESS;
  980. end;
  981. LPSOCKET_ADDRESS_LIST = ^TSOCKET_ADDRESS_LIST;
  982. PSOCKET_ADDRESS_LIST = ^TSOCKET_ADDRESS_LIST;
  983. { Address Family/Protocol Tuples }
  984. TAFPROTOCOLS = record
  985. iAddressFamily : tOS_INT;
  986. iProtocol : tOS_INT;
  987. end;
  988. PAFPROTOCOLS = ^TAFPROTOCOLS;
  989. LPAFPROTOCOLS = ^TAFPROTOCOLS;
  990. { Client Query API Typedefs }
  991. { The comparators }
  992. TWSAEcomparator = (COMP_EQUAL := 0,COMP_NOTLESS);
  993. PWSAECOMPARATOR = ^TWSAEcomparator;
  994. LPWSAECOMPARATOR = ^TWSAEcomparator;
  995. TWSAVersion = record
  996. dwVersion : DWORD;
  997. ecHow : TWSAECOMPARATOR;
  998. end;
  999. PWSAVERSION = ^TWSAVersion;
  1000. LPWSAVERSION = ^TWSAVersion;
  1001. TWSAQuerySetA = record
  1002. dwSize : DWORD;
  1003. lpszServiceInstanceName : PChar;
  1004. lpServiceClassId : LPGUID;
  1005. lpVersion : LPWSAVERSION;
  1006. lpszComment : PChar;
  1007. dwNameSpace : DWORD;
  1008. lpNSProviderId : LPGUID;
  1009. lpszContext : PChar;
  1010. dwNumberOfProtocols : DWORD;
  1011. lpafpProtocols : LPAFPROTOCOLS;
  1012. lpszQueryString : PChar;
  1013. dwNumberOfCsAddrs : DWORD;
  1014. lpcsaBuffer : LPCSADDR_INFO;
  1015. dwOutputFlags : DWORD;
  1016. lpBlob : PBLOB;
  1017. end;
  1018. PWSAQUERYSETA = ^TWSAQuerySetA;
  1019. LPWSAQUERYSETA = ^TWSAQuerySetA;
  1020. TWSAQuerySetW = record
  1021. dwSize : DWORD;
  1022. lpszServiceInstanceName : PWideChar;
  1023. lpServiceClassId : LPGUID;
  1024. lpVersion : LPWSAVERSION;
  1025. lpszComment : PWideChar;
  1026. dwNameSpace : DWORD;
  1027. lpNSProviderId : LPGUID;
  1028. lpszContext : PWideChar;
  1029. dwNumberOfProtocols : DWORD;
  1030. lpafpProtocols : LPAFPROTOCOLS;
  1031. lpszQueryString : PWideChar;
  1032. dwNumberOfCsAddrs : DWORD;
  1033. lpcsaBuffer : LPCSADDR_INFO;
  1034. dwOutputFlags : DWORD;
  1035. lpBlob : PBLOB;
  1036. end;
  1037. PWSAQUERYSETW = ^TWSAQuerySetW;
  1038. LPWSAQUERYSETW = ^TWSAQuerySetW;
  1039. {$ifdef UNICODE}
  1040. type
  1041. TWSAQUERYSET = TWSAQUERYSETW;
  1042. PWSAQUERYSET = PWSAQUERYSETW;
  1043. LPWSAQUERYSET = LPWSAQUERYSETW;
  1044. {$else}
  1045. type
  1046. TWSAQUERYSET = TWSAQUERYSETA;
  1047. PWSAQUERYSET = PWSAQUERYSETA;
  1048. LPWSAQUERYSET = LPWSAQUERYSETA;
  1049. {$endif}
  1050. const
  1051. LUP_DEEP = $0001;
  1052. LUP_CONTAINERS = $0002;
  1053. LUP_NOCONTAINERS = $0004;
  1054. LUP_NEAREST = $0008;
  1055. LUP_RETURN_NAME = $0010;
  1056. LUP_RETURN_TYPE = $0020;
  1057. LUP_RETURN_VERSION = $0040;
  1058. LUP_RETURN_COMMENT = $0080;
  1059. LUP_RETURN_ADDR = $0100;
  1060. LUP_RETURN_BLOB = $0200;
  1061. LUP_RETURN_ALIASES = $0400;
  1062. LUP_RETURN_QUERY_STRING = $0800;
  1063. LUP_RETURN_ALL = $0FF0;
  1064. LUP_RES_SERVICE = $8000;
  1065. LUP_FLUSHCACHE = $1000;
  1066. LUP_FLUSHPREVIOUS = $2000;
  1067. { }
  1068. { Return flags }
  1069. { }
  1070. RESULT_IS_ALIAS = $0001;
  1071. { Service Address Registration and Deregistration Data Types. }
  1072. type
  1073. TWSAESETSERVICEOP =
  1074. (RNRSERVICE_REGISTER := 0,RNRSERVICE_DEREGISTER, RNRSERVICE_DELETE);
  1075. PWSAESETSERVICEOP = ^TWSAESETSERVICEOP;
  1076. LPWSAESETSERVICEOP = ^TWSAESETSERVICEOP;
  1077. { Service Installation/Removal Data Types. }
  1078. TWSANSClassInfoA = record
  1079. lpszName : PChar;
  1080. dwNameSpace : DWORD;
  1081. dwValueType : DWORD;
  1082. dwValueSize : DWORD;
  1083. lpValue : Pointer;
  1084. end;
  1085. PWSANSCLASSINFOA = ^TWSANSClassInfoA;
  1086. LPWSANSCLASSINFOA = ^TWSANSClassInfoA;
  1087. TWSANSClassInfoW = record
  1088. lpszName : PWideChar;
  1089. dwNameSpace : DWORD;
  1090. dwValueType : DWORD;
  1091. dwValueSize : DWORD;
  1092. lpValue : Pointer;
  1093. end;
  1094. PWSANSCLASSINFOW = ^TWSANSClassInfoW;
  1095. LPWSANSCLASSINFOW = ^TWSANSClassInfoW;
  1096. {$ifdef UNICODE}
  1097. type
  1098. TWSANSCLASSINFO = TWSANSCLASSINFOW;
  1099. PWSANSCLASSINFO = PWSANSCLASSINFOW;
  1100. LPWSANSCLASSINFO = LPWSANSCLASSINFOW;
  1101. {$else}
  1102. type
  1103. TWSANSCLASSINFO = TWSANSCLASSINFOA;
  1104. PWSANSCLASSINFO = PWSANSCLASSINFOA;
  1105. LPWSANSCLASSINFO = LPWSANSCLASSINFOA;
  1106. {$endif}
  1107. type
  1108. TWSAServiceClassInfoA = record
  1109. lpServiceClassId : LPGUID;
  1110. lpszServiceClassName : PChar;
  1111. dwCount : DWORD;
  1112. lpClassInfos : LPWSANSCLASSINFOA;
  1113. end;
  1114. PWSASERVICECLASSINFOA = ^TWSAServiceClassInfoA;
  1115. LPWSASERVICECLASSINFOA = ^TWSAServiceClassInfoA;
  1116. TWSAServiceClassInfoW = record
  1117. lpServiceClassId : LPGUID;
  1118. lpszServiceClassName : PWideChar;
  1119. dwCount : DWORD;
  1120. lpClassInfos : LPWSANSCLASSINFOW;
  1121. end;
  1122. PWSASERVICECLASSINFOW = ^TWSAServiceClassInfoW;
  1123. LPWSASERVICECLASSINFOW = ^TWSAServiceClassInfoW;
  1124. {$ifdef UNICODE}
  1125. type
  1126. TWSASERVICECLASSINFO = TWSASERVICECLASSINFOW;
  1127. PWSASERVICECLASSINFO = PWSASERVICECLASSINFOW;
  1128. LPWSASERVICECLASSINFO = LPWSASERVICECLASSINFOW;
  1129. {$else}
  1130. type
  1131. TWSASERVICECLASSINFO = TWSASERVICECLASSINFOA;
  1132. PWSASERVICECLASSINFO = PWSASERVICECLASSINFOA;
  1133. LPWSASERVICECLASSINFO = LPWSASERVICECLASSINFOA;
  1134. {$endif}
  1135. type
  1136. TWSANAMESPACE_INFOA = record
  1137. NSProviderId : TGUID;
  1138. dwNameSpace : DWORD;
  1139. fActive : BOOL;
  1140. dwVersion : DWORD;
  1141. lpszIdentifier: PChar;
  1142. end;
  1143. PWSANAMESPACE_INFOA = ^TWSANAMESPACE_INFOA;
  1144. LPWSANAMESPACE_INFOA = ^TWSANAMESPACE_INFOA;
  1145. TWSANAMESPACE_INFOW = record
  1146. NSProviderId : TGUID;
  1147. dwNameSpace : DWORD;
  1148. fActive : BOOL;
  1149. dwVersion : DWORD;
  1150. lpszIdentifier: PWideChar;
  1151. end;
  1152. PWSANAMESPACE_INFOW = ^TWSANAMESPACE_INFOW;
  1153. LPWSANAMESPACE_INFOW = ^TWSANAMESPACE_INFOW;
  1154. {$ifdef UNICODE}
  1155. type
  1156. TWSANAMESPACE_INFO = TWSANAMESPACE_INFOW;
  1157. PWSANAMESPACE_INFO = PWSANAMESPACE_INFOW;
  1158. LPWSANAMESPACE_INFO = LPWSANAMESPACE_INFOW;
  1159. {$else}
  1160. type
  1161. TWSANAMESPACE_INFO = TWSANAMESPACE_INFOA;
  1162. PWSANAMESPACE_INFO = PWSANAMESPACE_INFOA;
  1163. LPWSANAMESPACE_INFO = LPWSANAMESPACE_INFOA;
  1164. {$endif}
  1165. { WinSock 2 extensions -- data types for the condition function in
  1166. WSAAccept() and overlapped I/O completion routine. }
  1167. type
  1168. TWSAOVERLAPPED_COMPLETION_ROUTINE =
  1169. function (dwError,cbTransferred : longint;
  1170. lpOverlapped : PWSAOVERLAPPED;
  1171. dwFlags : longint) : longint;
  1172. {$ifdef netware} cdecl; {$else} stdcall; {$endif}
  1173. TCONDITIONPROC =
  1174. function (lpCallerId, lpCallerData : PWSABUF;
  1175. lpSQOS, lpGQOS : PQOS;
  1176. lpCalleeId, lpCalleeData : PWSABUF;
  1177. g : PGROUP;
  1178. dwCallbackData : dword) : longint;
  1179. {$ifdef netware} cdecl; {$else} stdcall; {$endif}
  1180. {--------------------------------------------------------------------}
  1181. {netware extensions from ws2nlm.h}
  1182. {$ifdef netware}
  1183. { New Address Types }
  1184. const
  1185. AF_INET_ACP = 25;
  1186. AF_IPX_ACP = 26;
  1187. AF_ACP = 27;
  1188. { NetWare SSL Ioctls }
  1189. const
  1190. SECURITY_PROTOCOL_SSL = 1;
  1191. SECURITY_PROTOCOL_TLS = 2;
  1192. { There are three interesting authentication types }
  1193. { CLIENT - Client initiates a SSL connection. }
  1194. { SERVER - Listener set up to listen for incoming SSL conns, (Server sends it's cert during auth) }
  1195. { MUTUAL is SSL Server requesting client authentication, (Server asks for client cert inaddition to sending it's cert) }
  1196. { optval is a DWORD defined as }
  1197. const
  1198. MUTUAL = $00000002;
  1199. { System flags not defined in NetWare }
  1200. const
  1201. INFINITE = $FFFFFFFF;
  1202. WAIT_OBJECT_0 = 0;
  1203. {Various Types that may not be defined }
  1204. { }
  1205. { }
  1206. { Predefined Value Types. }
  1207. { }
  1208. { No value type }
  1209. const
  1210. REG_NONE = 0;
  1211. REG_SZ = 1;
  1212. REG_EXPAND_SZ = 2;
  1213. REG_BINARY = 3;
  1214. REG_DWORD = 4;
  1215. REG_DWORD_LITTLE_ENDIAN = 4;
  1216. REG_DWORD_BIG_ENDIAN = 5;
  1217. REG_LINK = 6;
  1218. REG_MULTI_SZ = 7;
  1219. REG_RESOURCE_LIST = 8;
  1220. REG_FULL_RESOURCE_DESCRIPTOR = 9;
  1221. REG_RESOURCE_REQUIREMENTS_LIST = 10;
  1222. ERROR_INVALID_HANDLE = 6;
  1223. ERROR_NOT_ENOUGH_MEMORY = 8;
  1224. ERROR_INVALID_PARAMETER = 87;
  1225. ERROR_IO_PENDING = 997;
  1226. ERROR_OPERATION_ABORTED = 995;
  1227. ERROR_IO_INCOMPLETE = 996;
  1228. { connect timeout }
  1229. const
  1230. SO_CONNTIMEO = $1009;
  1231. { NetWare Fast Accept and Recv option structures }
  1232. { Fast Recv also has a cleanup routine returned. }
  1233. type
  1234. LPFASTACCEPT_COMPLETION_ROUTINE = longint;
  1235. LPFASTRECV_COMPLETION_ROUTINE = longint;
  1236. TFASTACCEPT_OP = record
  1237. acceptHandler : LPFASTACCEPT_COMPLETION_ROUTINE;
  1238. arg : pointer;
  1239. end;
  1240. LPFAST_ACCEPT_OPT = ^TFASTACCEPT_OP;
  1241. PFAST_ACCEPT_OPT = ^TFASTACCEPT_OP;
  1242. TFASTRECV_OP = record
  1243. recvHandler : LPFASTRECV_COMPLETION_ROUTINE;
  1244. Arg : pointer;
  1245. end;
  1246. LPFAST_RECV_OPT = ^TFASTRECV_OP;
  1247. PFAST_RECV_OPT = ^TFASTRECV_OP;
  1248. { Winsock 2 applications that want to use SSL need to define WS_SSL }
  1249. type
  1250. time_t = dword;
  1251. { Secure Sockets Layer - needed until Winsock SDK supplies ssl header file. }
  1252. { Taken from Winsock 2 protocol Annex for SSL Security Protocol. Unsupported }
  1253. { options are labeled "not supported". }
  1254. { This value is the SSL protocol tag and WSAIoctl dwIoControlCode
  1255. "T" value. }
  1256. const
  1257. _SO_SSL = (2 shl 27) or ($73 shl 16);
  1258. {
  1259. These values are used to form the WSAIoctl dwIoControlCode
  1260. "Code" value.
  1261. }
  1262. _SO_SSL_FLAGS = $01;
  1263. _SO_SSL_CIPHERS = $02;
  1264. _SO_SSL_SERVER = $04;
  1265. { not supported }
  1266. _SO_SSL_AUTH_CERT_HOOK = $08;
  1267. { not supported }
  1268. _SO_SSL_RSA_ENCRYPT_HOOK = $10;
  1269. { not supported }
  1270. _SO_SSL_RSA_DECRYPT_HOOK = $20;
  1271. { _SO_SSL_CLIENT has been changed from 0x03 to 0x80 to avoid bitwise }
  1272. { conflicts with _SO_SSL_CIPHERS _SO_SSL_FLAGS. }
  1273. _SO_SSL_CLIENT = $80;
  1274. { Actual SSL Ioctl commands }
  1275. SO_SSL_GET_FLAGS = (IOC_IN or _SO_SSL) or _SO_SSL_FLAGS;
  1276. SO_SSL_SET_FLAGS = (IOC_OUT or _SO_SSL) or _SO_SSL_FLAGS;
  1277. SO_SSL_GET_CIPHERS = (IOC_IN or _SO_SSL) or _SO_SSL_CIPHERS;
  1278. {not supported }
  1279. SO_SSL_SET_CIPHERS = (IOC_OUT or _SO_SSL) or _SO_SSL_CIPHERS;
  1280. SO_SSL_GET_CLIENT = (IOC_IN or _SO_SSL) or _SO_SSL_CLIENT;
  1281. SO_SSL_SET_CLIENT = (IOC_OUT or _SO_SSL) or _SO_SSL_CLIENT;
  1282. SO_SSL_GET_SERVER = (IOC_IN or _SO_SSL) or _SO_SSL_SERVER;
  1283. SO_SSL_SET_SERVER = (IOC_OUT or _SO_SSL) or _SO_SSL_SERVER;
  1284. {not supported }
  1285. SO_SSL_GET_AUTH_CERT_HOOK = (IOC_IN or _SO_SSL) or _SO_SSL_AUTH_CERT_HOOK;
  1286. {not supported }
  1287. SO_SSL_SET_AUTH_CERT_HOOK = (IOC_OUT or _SO_SSL) or _SO_SSL_AUTH_CERT_HOOK;
  1288. {not supported }
  1289. SO_SSL_GET_RSA_ENCRYPT_HOOK = (IOC_IN or _SO_SSL) or _SO_SSL_RSA_ENCRYPT_HOOK;
  1290. {not supported }
  1291. SO_SSL_SET_RSA_ENCRYPT_HOOK = (IOC_OUT or _SO_SSL) or _SO_SSL_RSA_ENCRYPT_HOOK;
  1292. {not supported }
  1293. SO_SSL_GET_RSA_DECRYPT_HOOK = (IOC_IN or _SO_SSL) or _SO_SSL_RSA_DECRYPT_HOOK;
  1294. {not supported }
  1295. SO_SSL_SET_RSA_DECRYPT_HOOK = (IOC_OUT or _SO_SSL) or _SO_SSL_RSA_DECRYPT_HOOK;
  1296. SO_SSL_ENABLE = $001;
  1297. SO_SSL_SERVER = $002;
  1298. SO_SSL_AUTH_CLIENT = $004;
  1299. {not supported }
  1300. SO_SSL_ACCEPT_WEAK = $008;
  1301. type
  1302. Tsslcipheropts = record
  1303. n : longint;
  1304. specs : array[0..2] of char;
  1305. end;
  1306. Tsslclientopts = record
  1307. cert : PChar;
  1308. certlen : longint;
  1309. sidtimeout : time_t;
  1310. sidentries : longint;
  1311. siddir : PChar;
  1312. end;
  1313. Tsslserveropts = record
  1314. cert : PChar;
  1315. certlen : longint;
  1316. sidtimeout : time_t;
  1317. sidentries : longint;
  1318. siddir : PChar;
  1319. end;
  1320. {not suppported }
  1321. {Tsslauthcertopts = record
  1322. _type : longint;
  1323. func : function (arg:pointer; cert:Pchar; len:longint):longint;cdecl;
  1324. arg : pointer;
  1325. end;}
  1326. {not supported }
  1327. const
  1328. SSL_ACK_OK = 1;
  1329. {not supported }
  1330. SSL_ACH_WEAK_OK = 2;
  1331. {not supported }
  1332. SSL_ACH_LONG_DATA = 3;
  1333. {not supported }
  1334. SSL_ACH_BAD_DATA = 4;
  1335. {not supported }
  1336. SSL_ACH_BAD_SIG = 5;
  1337. {not supported }
  1338. SSL_ACH_CERT_EXPIRED = 6;
  1339. {not suppported }
  1340. type
  1341. sslrsaencrypthook = record
  1342. func : function (arg:pointer; blockType:longint; dest:Pchar; destlen:Plongint; src:Pchar;
  1343. srclen:longint):longint; cdecl;
  1344. arg : pointer;
  1345. end;
  1346. {not supported }
  1347. const
  1348. SSL_REH_OK = 0;
  1349. {not supported }
  1350. SSL_REH_BAD_TYPE = 1;
  1351. {not supported }
  1352. SSL_REH_BAD_LEN = 2;
  1353. {not suppported }
  1354. type
  1355. Tsslrsadecrypthook = record
  1356. func : function (arg:pointer; blockType:longint; dest:Pchar; destlen:Plongint; src:Pchar;
  1357. srclen:longint):longint; cdecl;
  1358. arg : pointer;
  1359. end;
  1360. Psslrsadecrypthook = ^Tsslrsadecrypthook;
  1361. {not supported }
  1362. const
  1363. SSL_RDH_OK = 0;
  1364. {not supported }
  1365. SSL_RDH_BAD_TYPE = 1;
  1366. {not supported }
  1367. SSL_RDH_BAD_LEN = 2;
  1368. { TLS options }
  1369. { Secure Sockets Layer - needed until Winsock SDK supplies ssl header file. }
  1370. { Taken from Winsock 2 protocol Annex for SSL Security Protocol. Unsupported }
  1371. { options are labeled "not supported". }
  1372. {
  1373. This value is the SSL protocol tag and WSAIoctl dwIoControlCode
  1374. "T" value. This value is unique to distinguish a TLS Ioctl from an SSL
  1375. Ioctl due to different structure definitions.
  1376. }
  1377. _SO_TLS = (2 shl 27) or ($74 shl 16);
  1378. {
  1379. These values are used to form the WSAIoctl dwIoControlCode
  1380. "Code" value.
  1381. }
  1382. _SO_TLS_FLAGS = $01;
  1383. _SO_TLS_CIPHERS = $02;
  1384. _SO_TLS_SERVER = $04;
  1385. { not supported }
  1386. _SO_TLS_AUTH_CERT_HOOK = $08;
  1387. { not supported }
  1388. _SO_TLS_RSA_ENCRYPT_HOOK = $10;
  1389. { not supported }
  1390. _SO_TLS_RSA_DECRYPT_HOOK = $20;
  1391. _SO_TLS_CERT = $40;
  1392. { _SO_TLS_CLIENT has been changed from 0x03 to 0x80 to avoid bitwise }
  1393. { conflicts with _SO_TLS_CIPHERS _SO_TLS_FLAGS. }
  1394. _SO_TLS_CLIENT = $80;
  1395. {
  1396. Actual TLS Ioctl commands
  1397. }
  1398. SO_TLS_GET_FLAGS = (IOC_IN or _SO_TLS) or _SO_TLS_FLAGS;
  1399. SO_TLS_SET_FLAGS = (IOC_OUT or _SO_TLS) or _SO_TLS_FLAGS;
  1400. SO_TLS_GET_CIPHERS = (IOC_IN or _SO_TLS) or _SO_TLS_CIPHERS;
  1401. {not supported }
  1402. SO_TLS_SET_CIPHERS = (IOC_OUT or _SO_TLS) or _SO_TLS_CIPHERS;
  1403. SO_TLS_GET_CLIENT = (IOC_IN or _SO_TLS) or _SO_TLS_CLIENT;
  1404. SO_TLS_SET_CLIENT = (IOC_OUT or _SO_TLS) or _SO_TLS_CLIENT;
  1405. SO_TLS_GET_SERVER = (IOC_IN or _SO_TLS) or _SO_TLS_SERVER;
  1406. SO_TLS_SET_SERVER = (IOC_OUT or _SO_TLS) or _SO_TLS_SERVER;
  1407. SO_TLS_GET_CERT = (IOC_IN or _SO_TLS) or _SO_TLS_CERT;
  1408. {not supported }
  1409. SO_TLS_GET_AUTH_CERT_HOOK = (IOC_IN or _SO_TLS) or _SO_TLS_AUTH_CERT_HOOK;
  1410. {not supported }
  1411. SO_TLS_SET_AUTH_CERT_HOOK = (IOC_OUT or _SO_TLS) or _SO_TLS_AUTH_CERT_HOOK;
  1412. {not supported }
  1413. SO_TLS_GET_RSA_ENCRYPT_HOOK = (IOC_IN or _SO_TLS) or _SO_TLS_RSA_ENCRYPT_HOOK;
  1414. {not supported }
  1415. SO_TLS_SET_RSA_ENCRYPT_HOOK = (IOC_OUT or _SO_TLS) or _SO_TLS_RSA_ENCRYPT_HOOK;
  1416. {not supported }
  1417. SO_TLS_GET_RSA_DECRYPT_HOOK = (IOC_IN or _SO_TLS) or _SO_TLS_RSA_DECRYPT_HOOK;
  1418. {not supported }
  1419. SO_TLS_SET_RSA_DECRYPT_HOOK = (IOC_OUT or _SO_TLS) or _SO_TLS_RSA_DECRYPT_HOOK;
  1420. SO_TLS_ENABLE = $0001;
  1421. SO_TLS_SERVER = $0002;
  1422. SO_TLS_AUTH_CLIENT = $0004;
  1423. {not supported }
  1424. SO_TLS_ACCEPT_WEAK = $0008;
  1425. SO_TLS_MAP_DISABLE = $0010;
  1426. SO_TLS_MAP_IDENTITY = $0020;
  1427. SO_TLS_BLIND_ACCEPT = $0040;
  1428. SO_TLS_INTERACTIVE_ACCEPT = $0080;
  1429. type
  1430. Ttlscipheropts = record
  1431. n : longint;
  1432. specs : array[0..2] of char;
  1433. end;
  1434. Ptlscipheropts = ^Ttlscipheropts;
  1435. Ttlsclientopts = record
  1436. wallet : PWideChar; // ^unicode;
  1437. walletlen : longint;
  1438. sidtimeout : time_t;
  1439. sidentries : longint;
  1440. siddir : PChar; // ^char;
  1441. options : pointer;
  1442. end;
  1443. Ptlsclientopts = ^Ttlsclientopts;
  1444. Ttlsserveropts = record
  1445. wallet : PWideChar; // ^unicode;
  1446. walletlen : longint;
  1447. sidtimeout : time_t;
  1448. sidentries : longint;
  1449. siddir : PChar; // ^char;
  1450. options : pointer;
  1451. end;
  1452. Ptlsserveropts = ^Ttlsserveropts;
  1453. {wallet content provider e.g. PFX, KMO, DER. }
  1454. {alias for private key in wallet to be used }
  1455. { not used for anything but pfx wallet provider }
  1456. {number of elements in the array }
  1457. {array of trusted root names }
  1458. {number of elements in the array }
  1459. {reserved to set ciphers }
  1460. {reserved for CRL }
  1461. {reserved for CRL len. }
  1462. Tnwtlsopts = record
  1463. walletProvider : PWideChar; //^unicode;
  1464. keysList : PPWideChar; // ^^unicode;
  1465. numElementsInKeyList : longint;
  1466. TrustedRootList : PPWideChar; // ^^unicode;
  1467. numElementsInTRList : longint;
  1468. reservedforfutureuse : pointer;
  1469. reservedforfutureCRL : pointer;
  1470. reservedforfutureCRLLen : longint;
  1471. reserved1 : pointer;
  1472. reserved2 : pointer;
  1473. reserved3 : pointer;
  1474. end;
  1475. Pnwtlsopts=^Tnwtlsopts;
  1476. {not suppported }
  1477. {tlsauthcertopts = record
  1478. _type : longint;
  1479. func : function (arg:pointer; cert:Pchar; len:longint):longint; cdecl;
  1480. arg : pointer;
  1481. end;}
  1482. {not supported }
  1483. const
  1484. TLS_ACK_OK = 1;
  1485. {not supported }
  1486. TLS_ACH_WEAK_OK = 2;
  1487. {not supported }
  1488. TLS_ACH_LONG_DATA = 3;
  1489. {not supported }
  1490. TLS_ACH_BAD_DATA = 4;
  1491. {not supported }
  1492. TLS_ACH_BAD_SIG = 5;
  1493. {not supported }
  1494. TLS_ACH_CERT_EXPIRED = 6;
  1495. {not suppported }
  1496. type
  1497. Ttlsrsaencrypthook = record
  1498. func : function (arg:pointer; blockType:longint; dest:Pchar; destlen:Plongint; src:Pchar;
  1499. srclen:longint):longint; cdecl;
  1500. arg : pointer;
  1501. end;
  1502. Ptlsrsaencrypthook=^Ttlsrsaencrypthook;
  1503. {not supported }
  1504. const
  1505. TLS_REH_OK = 0;
  1506. {not supported }
  1507. TLS_REH_BAD_TYPE = 1;
  1508. {not supported }
  1509. TLS_REH_BAD_LEN = 2;
  1510. {not suppported }
  1511. type
  1512. Ttlsrsadecrypthook = record
  1513. func : function (arg:pointer; blockType:longint; dest:Pchar; destlen:Plongint; src:Pchar;
  1514. srclen:longint):longint; cdecl;
  1515. arg : pointer;
  1516. end;
  1517. Ptlsrsadecrypthook=^Ttlsrsadecrypthook;
  1518. {not supported }
  1519. const
  1520. TLS_RDH_OK = 0;
  1521. {not supported }
  1522. TLS_RDH_BAD_TYPE = 1;
  1523. {not supported }
  1524. TLS_RDH_BAD_LEN = 2;
  1525. type
  1526. Ttlscert = record
  1527. cert : PChar;
  1528. certlen : longint;
  1529. end;
  1530. Ptlscert = ^Ttlscert;
  1531. const SIO_RAWCALLBACKS = $1ADD0002;
  1532. SIO_WORKTODOCALLBACKS = $1ADD0004;
  1533. SIO_FASTACCEPTCALLBACK = $1ADD0008;
  1534. SIO_FASTRECVCALLBACK = $1ADD000C;
  1535. SIO_RCVFULLMSG = $1ADD0010;
  1536. SIO_SSL_CRYPTFILE = $1ADD0010;
  1537. SIO_SSL_AUTHTYPE = $1ADD0020;
  1538. SIO_SSL_CONVERT = $1ADD0040;
  1539. SKTS_RAWCALLBACKS = $40000000;
  1540. SKTS_WORKTODOCALLBACKS = $20000000;
  1541. WAIT_ABANDONED = $00000080;
  1542. WAIT_TIMEOUT = $00000102;
  1543. WAIT_FAILED = $FFFFFFFF;
  1544. MAXIMUM_WAIT_OBJECTS = 64;
  1545. WAIT_IO_COMPLETION = $000000C0;
  1546. { This file contains proposed extensions to the Winsock 2 specification to }
  1547. { support Novell's implementation of namespace providers. }
  1548. {___[ Manifest constants ]________________________________________________________________________ }
  1549. { Proposed output flag for deregistered services }
  1550. const
  1551. RESULT_IS_DEREGISTERED = $0002;
  1552. { Proposed output flag for containers }
  1553. RESULT_IS_CONTAINER = $0004;
  1554. { Values used to indicate an attribute list in the blob }
  1555. { blob contains ASCII strings }
  1556. WS_ATTRLIST_ASCII = $b10bea1a;
  1557. { blob contains UNICODE strings }
  1558. WS_ATTRLIST_UNICODE = $b10bea10;
  1559. { Name Spaces }
  1560. { Extends definitions in WINSOCK2.H }
  1561. NS_BINDERY = 4;
  1562. NS_SLP = 5;
  1563. { Predefined BLOB Value Types }
  1564. { Extends Predefined Value Types in winnt.h }
  1565. { }
  1566. {#define REG_SZ ( 1 ) // Unicode NULL terminated string }
  1567. {#define REG_BINARY ( 3 ) // Free form binary }
  1568. {#define REG_DWORD ( 4 ) // 32-bit number }
  1569. { Boolian value; TRUE or FALSE }
  1570. REG_BOOL = 11;
  1571. { Keyword with no value }
  1572. REG_KEYWORD = 12;
  1573. {___[ Type definitions ]__________________________________________________________________________ }
  1574. type
  1575. TWSAATTRINFO = TWSANSCLASSINFO;
  1576. LPWSAATTRINFO = ^TWSAATTRINFO;
  1577. PWSAATTRINFO = ^TWSAATTRINFO;
  1578. { Structure of a blob containing an attribute list }
  1579. { Identifies the blob as an attribute list }
  1580. { Number of attributes present }
  1581. { Pointer to attribute array }
  1582. TWSABlobAttrList = record
  1583. dwSignature : DWORD;
  1584. dwAttrCount : DWORD;
  1585. lpAttributes : PWSAATTRINFO;
  1586. end;
  1587. LPWSABLOBATTRLIST = ^TWSABlobAttrList;
  1588. PWSABLOBATTRLIST = ^TWSABlobAttrList;
  1589. {$endif netware}
  1590. {--------------------------------------------------------------------}
  1591. { Socket function prototypes }
  1592. const
  1593. {$ifndef netware}
  1594. winsockdll = 'ws2_32.dll';
  1595. _fn_bind = 'bind';
  1596. _fn_closesocket = 'closesocket';
  1597. _fn_ioctlsocket = 'ioctlsocket';
  1598. _fn_getpeername = 'getpeername';
  1599. _fn_getsockopt = 'getsockopt';
  1600. _fn_htonl = 'htonl';
  1601. _fn_htons = 'htons';
  1602. _fn_inet_addr = 'inet_addr';
  1603. _fn_inet_ntoa = 'inet_ntoa';
  1604. _fn_listen = 'listen';
  1605. _fn_recv = 'recv';
  1606. _fn_recvfrom = 'recvfrom';
  1607. _fn_select = 'select';
  1608. _fn_send = 'send';
  1609. _fn_sendto = 'sendto';
  1610. _fn_setsockopt = 'setsockopt';
  1611. _fn_shutdown = 'shutdown';
  1612. _fn_socket = 'socket';
  1613. _fn_gethostbyaddr = 'gethostbyaddr';
  1614. _fn_gethostbyname = 'gethostbyname';
  1615. _fn_gethostname = 'gethostname';
  1616. _fn_getservbyport = 'getservbyport';
  1617. _fn_getservbyname = 'getservbyname';
  1618. _fn_getprotobynumber = 'getprotobynumber';
  1619. _fn_getprotobyname = 'getprotobyname';
  1620. {$else}
  1621. winsockdll = 'ws2_32.nlm';
  1622. {for netware the function names for the non WSA-functions are
  1623. different because the names are already present from bsd-sockets}
  1624. _fn_bind = 'WS2_32_bind';
  1625. _fn_closesocket = 'WS2_32_closesocket';
  1626. _fn_ioctlsocket = 'WS2_32_ioctlsocket';
  1627. _fn_getpeername = 'WS2_32_getpeername';
  1628. _fn_getsockopt = 'WS2_32_getsockopt';
  1629. _fn_htonl = 'WS2_32_htonl';
  1630. _fn_htons = 'WS2_32_htons';
  1631. _fn_inet_addr = 'WS2_32_inet_addr';
  1632. _fn_inet_ntoa = 'WS2_32_inet_ntoa';
  1633. _fn_listen = 'WS2_32_listen';
  1634. _fn_recv = 'WS2_32_recv';
  1635. _fn_recvfrom = 'WS2_32_recvfrom';
  1636. _fn_select = 'WS2_32_select';
  1637. _fn_send = 'WS2_32_send';
  1638. _fn_sendto = 'WS2_32_sendto';
  1639. _fn_setsockopt = 'WS2_32_setsockopt';
  1640. _fn_shutdown = 'WS2_32_shutdown';
  1641. _fn_socket = 'WS2_32_socket';
  1642. _fn_gethostbyaddr = 'WS2_32_gethostbyaddr';
  1643. _fn_gethostbyname = 'WS2_32_gethostbyname';
  1644. _fn_gethostname = 'WS2_32_gethostname';
  1645. _fn_getservbyport = 'WS2_32_getservbyport';
  1646. _fn_getservbyname = 'WS2_32_getservbyname';
  1647. _fn_getprotobynumber = 'WS2_32_getprotobynumber';
  1648. _fn_getprotobyname = 'WS2_32_getprotobyname';
  1649. {$endif}
  1650. {$ifdef netware}
  1651. function accept(s:TSocket; addr: PSockAddr; addrlen : ptOS_INT) : TSocket;
  1652. function accept(s:TSocket; addr: PSockAddr; var addrlen : tOS_INT) : TSocket;
  1653. {$else}
  1654. function accept(s:TSocket; addr: PSockAddr; addrlen : ptOS_INT) : TSocket;stdcall;external winsockdll name 'accept';
  1655. function accept(s:TSocket; addr: PSockAddr; var addrlen : tOS_INT) : TSocket;stdcall;external winsockdll name 'accept';
  1656. {$endif}
  1657. function bind(s:TSocket; addr: PSockaddr;namelen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_Bind;
  1658. function bind(s:TSocket; var addr: TSockaddr;namelen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_Bind;
  1659. function closesocket(s:TSocket):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_closesocket;
  1660. {$ifdef netware}
  1661. function connect(s:TSocket; addr:PSockAddr; namelen:tOS_INT):tOS_INT;
  1662. function connect(s:TSocket; var name:TSockAddr; namelen:tOS_INT):tOS_INT;
  1663. {$else}
  1664. function connect(s:TSocket; addr:PSockAddr; namelen:tOS_INT):tOS_INT;
  1665. stdcall;external winsockdll name 'connect';
  1666. function connect(s:TSocket; var name:TSockAddr; namelen:tOS_INT):tOS_INT;
  1667. stdcall;external winsockdll name 'connect';
  1668. {$endif}
  1669. function ioctlsocket(s:TSocket; cmd:longint; var arg:u_long):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_ioctlsocket; { really a c-long }
  1670. function ioctlsocket(s:TSocket; cmd:longint; argp:pu_long):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_ioctlsocket; { really a c-long }
  1671. function getpeername(s:TSocket; var name:TSockAddr;var namelen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name _fn_getpeername;
  1672. function getsockname(s:TSocket; var name:TSockAddr;var namelen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name _fn_getpeername;
  1673. function getsockopt(s:TSocket; level:tOS_INT; optname:tOS_INT; optval:pchar;var optlen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name _fn_getsockopt;
  1674. function getsockopt(s:TSocket; level:tOS_INT; optname:tOS_INT;var optval;var optlen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name _fn_getsockopt;
  1675. function htonl(hostlong:u_long):u_long;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_htonl;
  1676. function htons(hostshort:u_short):u_short;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_htons;
  1677. function inet_addr(cp:pchar):cardinal;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_inet_addr;
  1678. function inet_ntoa(i : TInAddr):pchar;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_inet_ntoa;
  1679. function listen(s:TSocket; backlog:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_listen;
  1680. { are ntohl and ntohs macros or bsd-functions (for netware) ?? }
  1681. {$ifndef netware}
  1682. function ntohl(netlong:u_long):u_long;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'ntohl';
  1683. function ntohs(netshort:u_short):u_short;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'ntohs';
  1684. {$endif}
  1685. function recv(s:TSocket;buf:pchar; len:tOS_INT; flags:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_recv;
  1686. function recv(s:TSocket;var buf; len:tOS_INT; flags:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_recv;
  1687. function recvfrom(s:TSocket;buf:pchar; len:tOS_INT; flags:tOS_INT;from:PSockAddr; fromlen:ptOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name _fn_recvfrom;
  1688. function recvfrom(s:TSocket;var buf; len:tOS_INT; flags:tOS_INT;var from:TSockAddr; var fromlen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name _fn_recvfrom;
  1689. function select(nfds:tOS_INT; readfds,writefds,exceptfds : PFDSet;timeout: PTimeVal):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  1690. external winsockdll name _fn_select;
  1691. function send(s:TSocket;const buf; len:tOS_INT; flags:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  1692. external winsockdll name _fn_send;
  1693. function sendto(s:TSocket; buf:pchar; len:tOS_INT; flags:tOS_INT;var toaddr:TSockAddr; tolen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  1694. external winsockdll name _fn_sendto;
  1695. function sendto(s:TSocket; const buf; len:tOS_INT; flags:tOS_INT;var toaddr:TSockAddr; tolen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  1696. external winsockdll name _fn_sendto;
  1697. function setsockopt(s:TSocket; level:tOS_INT; optname:tOS_INT; optval:pchar; optlen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  1698. external winsockdll name _fn_setsockopt;
  1699. function setsockopt(s:TSocket; level:tOS_INT; optname:tOS_INT; var optval; optlen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  1700. external winsockdll name _fn_setsockopt;
  1701. function setsockopt(s:TSocket; level:tOS_INT; optname:tOS_INT; optval:pointer; optlen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  1702. external winsockdll name _fn_setsockopt;
  1703. function shutdown(s:TSocket; how:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  1704. external winsockdll name _fn_shutdown;
  1705. function socket(af:tOS_INT; t:tOS_INT; protocol:tOS_INT):TSocket;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  1706. external winsockdll name _fn_socket;
  1707. { Database function prototypes }
  1708. function gethostbyaddr(addr:pchar; len:tOS_INT; t:tOS_INT): PHostEnt;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_gethostbyaddr;
  1709. function gethostbyname(name:pchar):PHostEnt;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_gethostbyname;
  1710. function gethostname(name:pchar; namelen:tOS_INT):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_gethostname;
  1711. function getservbyport(port:tOS_INT; proto:pchar):PServEnt;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_getservbyport;
  1712. function getservbyname(name:pchar; proto:pchar):PServEnt;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_getservbyname;
  1713. function getprotobynumber(proto:tOS_INT):PProtoEnt;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_getprotobynumber;
  1714. function getprotobyname(name:pchar):PProtoEnt;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name _fn_getprotobyname;
  1715. { Microsoft Windows Extension function prototypes }
  1716. function WSAStartup(wVersionRequired:word;var WSAData:TWSADATA):tOS_INT;
  1717. function WSACleanup:tOS_INT;
  1718. procedure WSASetLastError(iError:tOS_INT);{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSASetLastError';
  1719. function WSAGetLastError:tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSAGetLastError';
  1720. {$ifndef netware}
  1721. //function WSAIsBlocking:BOOL;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSAIsBlocking';
  1722. // function WSAUnhookBlockingHook:tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSAUnhookBlockingHook';
  1723. // function WSASetBlockingHook(lpBlockFunc:TFarProc):TFarProc;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSASetBlockingHook';
  1724. {$endif}
  1725. function WSACancelBlockingCall:tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSACancelBlockingCall';
  1726. {$ifndef netware}
  1727. function WSAAsyncGetServByName(hWnd:HWND; wMsg:u_int; name:pchar; proto:pchar; buf:pchar;
  1728. buflen:tOS_INT):THandle;stdcall;external winsockdll name 'WSAAsyncGetServByName';
  1729. function WSAAsyncGetServByPort(hWnd:HWND; wMsg:u_int; port:tOS_INT; proto:pchar; buf:pchar;
  1730. buflen:tOS_INT):THandle;stdcall;external winsockdll name 'WSAAsyncGetServByPort';
  1731. function WSAAsyncGetProtoByName(hWnd:HWND; wMsg:u_int; name:pchar; buf:pchar; buflen:tOS_INT):THandle;stdcall;
  1732. external winsockdll name 'WSAAsyncGetProtoByName';
  1733. function WSAAsyncGetProtoByNumber(hWnd:HWND; wMsg:u_int; number:tOS_INT; buf:pchar; buflen:tOS_INT):THandle;stdcall;
  1734. external winsockdll name 'WSAAsyncGetProtoByNumber';
  1735. function WSAAsyncGetHostByName(hWnd:HWND; wMsg:u_int; name:pchar; buf:pchar; buflen:tOS_INT):THandle;stdcall;
  1736. external winsockdll name 'WSAAsyncGetHostByName';
  1737. function WSAAsyncGetHostByAddr(hWnd:HWND; wMsg:u_int; addr:pchar; len:tOS_INT; t:tOS_INT;
  1738. buf:pchar; buflen:tOS_INT):THandle;stdcall;
  1739. external winsockdll name 'WSAAsyncGetHostByAddr';
  1740. function WSACancelAsyncRequest(hAsyncTaskHandle:THandle):tOS_INT;stdcall;
  1741. external winsockdll name 'WSACancelAsyncRequest';
  1742. function WSAAsyncSelect(s:TSocket; hWnd:HWND; wMsg:u_int; lEvent:longint):tOS_INT; stdcall;
  1743. external winsockdll name 'WSAAsyncSelect';
  1744. function WSARecvEx(s:TSocket;var buf; len:tOS_INT; flags:ptOS_INT):tOS_INT;stdcall;
  1745. external winsockdll name 'WSARecvEx';
  1746. {$endif}
  1747. function __WSAFDIsSet(s:TSocket; var FDSet:TFDSet):Bool;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  1748. external winsockdll name '__WSAFDIsSet';
  1749. function __WSAFDIsSet_(s:TSocket; var FDSet:TFDSet):tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  1750. external winsockdll name '__WSAFDIsSet';
  1751. function FD_ISSET(s:TSocket; var FDSet:TFDSet):Bool;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  1752. external winsockdll name '__WSAFDIsSet';
  1753. {$ifndef netware}
  1754. function TransmitFile(hSocket:TSocket; hFile:THandle; nNumberOfBytesToWrite:dword;
  1755. nNumberOfBytesPerSend:DWORD; lpOverlapped:POverlapped;
  1756. lpTransmitBuffers:PTransmitFileBuffers; dwReserved:dword):Bool;stdcall;
  1757. external winsockdll name 'TransmitFile';
  1758. function AcceptEx(sListenSocket,sAcceptSocket:TSocket;
  1759. lpOutputBuffer:Pointer; dwReceiveDataLength,dwLocalAddressLength,
  1760. dwRemoteAddressLength:dword; var lpdwBytesReceived:dword;
  1761. lpOverlapped:POverlapped):Bool;stdcall;
  1762. external winsockdll name 'AcceptEx';
  1763. procedure GetAcceptExSockaddrs(lpOutputBuffer:Pointer;
  1764. dwReceiveDataLength,dwLocalAddressLength,dwRemoteAddressLength:dword;
  1765. var LocalSockaddr:TSockAddr; var LocalSockaddrLength:tOS_INT;
  1766. var RemoteSockaddr:TSockAddr; var RemoteSockaddrLength:tOS_INT);stdcall;
  1767. external winsockdll name 'GetAcceptExSockaddrs';
  1768. {$endif}
  1769. function WSAMakeSyncReply(Buflen,Error:Word):dword;
  1770. function WSAMakeSelectReply(Event,Error:Word):dword;
  1771. function WSAGetAsyncBuflen(Param:dword):Word;
  1772. function WSAGetAsyncError(Param:dword):Word;
  1773. function WSAGetSelectEvent(Param:dword):Word;
  1774. function WSAGetSelectError(Param:dword):Word;
  1775. procedure FD_CLR(Socket:TSocket; var FDSet:TFDSet);
  1776. {function FD_ISSET(Socket:TSocket; var FDSet:TFDSet):Boolean;}
  1777. procedure FD_SET(Socket:TSocket; var FDSet:TFDSet);
  1778. procedure FD_ZERO(var FDSet:TFDSet);
  1779. function MAKELONG(a,b : longint) : LONGINT;
  1780. function MAKEWORD(a,b : longint) : WORD;
  1781. { WinSock 2 API new function prototypes }
  1782. function WSAAccept(s: TSocket; addr:PSockAddr; addrlen : ptOS_INT;
  1783. lpfnCondition : TCONDITIONPROC;
  1784. dwCallbackData: dword) : longint;
  1785. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAAccept';
  1786. function WSAAccept(s: TSocket; addr:PSockAddr; var addrlen:longint;
  1787. lpfnCondition : TCONDITIONPROC;
  1788. dwCallbackData: dword) : longint;
  1789. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAAccept';
  1790. function WSACloseEvent (hEvent : TWSAEVENT) : longint;
  1791. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSACloseEvent';
  1792. function WSAconnect (s:TSocket; var name:TSockAddr;
  1793. namelen: tOS_INT;
  1794. lpCallerData, lpCaleeData : PWSABUF;
  1795. lpSQOS, lpGQOS : PQOS) : tOS_INT;
  1796. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAConnect';
  1797. function WSAconnect (s:TSocket; name:PSockAddr;
  1798. namelen: tOS_INT;
  1799. lpCallerData, lpCaleeData : PWSABUF;
  1800. lpSQOS, lpGQOS : PQOS) : tOS_INT;
  1801. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAConnect';
  1802. {$ifndef netware}
  1803. function WSADuplicateSocket (s:TSocket; dwProcessId:dword; lpProtoInfo: PWSAPROTOCOL_INFOA) : longint;
  1804. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSADuplicateSocketA';
  1805. {$endif}
  1806. function WSAEnumNetworkEvents(s:TSocket;hEventObject:TWSAEVENT;lpNetworkEvents:PWSANETWORKEVENTS): longint;
  1807. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAEnumNetworkEvents';
  1808. function WSAEnumProtocols (lpiProtocols:LPINT;
  1809. lpProtocolBuffer:PWSAPROTOCOL_INFOA;
  1810. var lpdwBufferLength : dword) : longint;
  1811. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAEnumProtocolsA';
  1812. function WSAEventSelect(s:TSocket; hEventObject: TWSAEvent;lNetworkEvents:longint):longint;
  1813. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAEventSelect';
  1814. function WSAGetOverlappedResult (s:TSocket;
  1815. lpOverlapped:PWSAOVERLAPPED;
  1816. lpcbTransfer : LPDWORD;
  1817. fWait : BOOL;
  1818. lpdwFlags : LPDWORD) : longint;
  1819. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAGetOverlappedResult';
  1820. function WSAGetQOSByName(s:TSocket; lpQOSName: LPWSABUF; lpQOS:PQOS) : longint;
  1821. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAGetQOSByName';
  1822. function WSAHtonl(s:TSocket; hostlong:u_long;lpnetlong:pu_long):longint;
  1823. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAHtonl';
  1824. function WSAHtonl(s:TSocket; hostlong:u_long;var lpnetlong:u_long):longint;
  1825. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAHtonl';
  1826. function WSAHtons(s:TSocket; hostshort:u_short;lpnetshort:pu_short):longint;
  1827. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAHtons';
  1828. function WSAHtons(s:TSocket; hostshort:u_short;var lpnetshort:u_short):longint;
  1829. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAHtons';
  1830. function WSAIoctl(s:TSocket;dwIoControlCode:dword;
  1831. lpvInBuffer:pointer; cbInBuffer:dword;
  1832. lpvOutBuffer:pointer; cbOutBuffer:dword;
  1833. lpcbBytesReturned:LPDWORD;
  1834. lpOverlapped:PWSAOVERLAPPED;
  1835. lpCompletionRoutine:TWSAOVERLAPPED_COMPLETION_ROUTINE):longint;
  1836. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAIoctl';
  1837. function WSAIoctl(s:TSocket;dwIoControlCode:dword;
  1838. var lpvInBuffer; cbInBuffer:dword;
  1839. var lpvOutBuffer; cbOutBuffer:dword;
  1840. var lpcbBytesReturned:DWORD;
  1841. lpOverlapped:PWSAOVERLAPPED;
  1842. lpCompletionRoutine:TWSAOVERLAPPED_COMPLETION_ROUTINE):longint;
  1843. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAIoctl';
  1844. function WSAJoinLeaf(s:TSocket; name: PSockAddr; namelen:longint;
  1845. lpCallerData,lpCalleeData:PWSABUF;
  1846. lpSQOS, lpGQOS : PQOS; dwFlags:dword):longint;
  1847. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAJoinLeaf';
  1848. function WSANtohl(s:TSocket;netlong:u_long;lphostlong:pu_long):longint;
  1849. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSANtohl';
  1850. function WSANtohl(s:TSocket;netlong:u_long;var hostlong:u_long):longint;
  1851. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSANtohl';
  1852. function WSANtohs(s:TSocket;netshort:u_short;lphostshort:pu_short):longint;
  1853. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSANtohs';
  1854. function WSANtohs(s:TSocket;netshort:u_short;var hostshort:u_short):longint;
  1855. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSANtohs';
  1856. function WSARecv(s:TSocket;buf:pchar; dwBufferCount:dword;
  1857. lpNumberOfBytesRecvd,lpFlags : LPDWORD;
  1858. lpOverlapped:PWSAOVERLAPPED;
  1859. lpCompletionRoutine:TWSAOVERLAPPED_COMPLETION_ROUTINE):longint;
  1860. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSARecv';
  1861. function WSARecv(s:TSocket;var buf; dwBufferCount:dword;
  1862. var lpNumberOfBytesRecvd,lpFlags : DWORD;
  1863. lpOverlapped:PWSAOVERLAPPED;
  1864. lpCompletionRoutine:TWSAOVERLAPPED_COMPLETION_ROUTINE):longint;
  1865. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSARecv';
  1866. function WSARecvDisconnect(s:TSocket;lpInboundDisconnectData:PWSABUF):longint;
  1867. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSARecvDisconnect';
  1868. function WSARecvDisconnect(s:TSocket;var InboundDisconnectData:TWSABUF):longint;
  1869. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSARecvDisconnect';
  1870. function WSARecvFrom(s:TSocket;buf:pchar; dwBufferCount:dword;
  1871. lpNumberOfBytesRecvd,lpFlags : LPDWORD;
  1872. lpFrom: PSockaddr;
  1873. lpFromlen: PDWORD;
  1874. lpOverlapped:PWSAOVERLAPPED;
  1875. lpCompletionRoutine:TWSAOVERLAPPED_COMPLETION_ROUTINE):longint;
  1876. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSARecvFrom';
  1877. function WSARecvFrom(s:TSocket;var buf; dwBufferCount:dword;
  1878. var lpNumberOfBytesRecvd,lpFlags : DWORD;
  1879. var lpFrom: TSockaddr;
  1880. var lpFromlen: DWORD;
  1881. lpOverlapped:PWSAOVERLAPPED;
  1882. lpCompletionRoutine:TWSAOVERLAPPED_COMPLETION_ROUTINE):longint;
  1883. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSARecvFrom';
  1884. function WSAResetEvent(hEvent:TWSAEVENT):BOOL;
  1885. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAResetEvent';
  1886. function WSASend(s:TSocket;buf:pchar;len:dword;
  1887. NumberOfBytesSent:PDWORD; Flags:dword;
  1888. lpOverlapped:PWSAOVERLAPPED;
  1889. lpCompletionRoutine:TWSAOVERLAPPED_COMPLETION_ROUTINE):longint;
  1890. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSASend';
  1891. function WSASend(s:TSocket;var buf;len:dword;
  1892. var NumberOfBytesSent: DWORD; Flags:dword;
  1893. lpOverlapped:PWSAOVERLAPPED;
  1894. lpCompletionRoutine:TWSAOVERLAPPED_COMPLETION_ROUTINE):longint;
  1895. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSASend';
  1896. function WSASendDisconnect(s:TSocket;lpOutboundDisconnectData:PWSABUF):longint;
  1897. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSASendDisconnect';
  1898. function WSASendTo(s:TSocket;buf:pchar;len:dword;
  1899. NumberOfBytesSent:LPDWORD;
  1900. Flags:dword;
  1901. lpTo: PSockaddr;
  1902. iToLen:dword;
  1903. lpOverlapped:PWSAOVERLAPPED;
  1904. lpCompletionRoutine:TWSAOVERLAPPED_COMPLETION_ROUTINE):longint;
  1905. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSASendTo';
  1906. function WSASendTo(s:TSocket;var buf;len:dword;
  1907. var NumberOfBytesSent:DWORD;
  1908. Flags:dword;
  1909. var lpTo: TSockaddr;
  1910. iToLen:dword;
  1911. lpOverlapped:PWSAOVERLAPPED;
  1912. lpCompletionRoutine:TWSAOVERLAPPED_COMPLETION_ROUTINE):longint;
  1913. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSASendTo';
  1914. function WSASetEvent(hEvent:TWSAEVENT):BOOL;
  1915. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSASetEvent';
  1916. function WSASocket(af,typ,proto:tOS_INT;
  1917. lpProtocolInfo:PWSAPROTOCOL_INFO;
  1918. g : TGROUP; Flags:dword):longint;
  1919. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSASocketA';
  1920. function WSAWaitForMultipleEvents(cEvents:dword;
  1921. lphEvents:pointer; {IN const WSAEVENT FAR * lphEvents,}
  1922. fWaitAll:BOOL; dwTimeout:dword; fAlertable:BOOL):longint;
  1923. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAWaitForMultipleEvents';
  1924. function WSAAddressToString(addr:PSockAddr; len:dword;
  1925. ProtocolInfo:PWSAPROTOCOL_INFO;
  1926. lpszAddressString:pchar;
  1927. lpdwAddressStringLength:lpdword):longint;
  1928. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAAddressToStringA';
  1929. function WSAAddressToString(var addr:TSockAddr; len:dword;
  1930. ProtocolInfo:PWSAPROTOCOL_INFO;
  1931. lpszAddressString:pchar;
  1932. var lpdwAddressStringLength:dword):longint;
  1933. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAAddressToStringA';
  1934. function WSAStringToAddress (AddressString : pchar;
  1935. AddressFamily : longint;
  1936. lpProtocolInfo : PWSAPROTOCOL_INFOA;
  1937. VAR lpAddress : TSOCKADDR;
  1938. VAR lpAddressLength: LONGINT) : longint;
  1939. {$ifdef Netware}cdecl;{$else}stdcall;{$endif} external winsockdll name 'WSAStringToAddressA';
  1940. function WSAStringToAddress (AddressString : pchar;
  1941. AddressFamily : longint;
  1942. lpProtocolInfo : PWSAPROTOCOL_INFOA;
  1943. lpAddress : PSOCKADDR;
  1944. VAR lpAddressLength: LONGINT) : longint;
  1945. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSAStringToAddressA';
  1946. function WSALookupServiceBegin(lpqsRestrictions:PWSAQUERYSET;
  1947. ControlFlags:dword;lphLookup:PHandle):longint;
  1948. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSALookupServiceBeginA';
  1949. function WSALookupServiceBegin(var Restrictions:TWSAQUERYSET;
  1950. ControlFlags:dword;var hLookup:THandle):longint;
  1951. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSALookupServiceBeginA';
  1952. function WSALookupServiceNext(hLookup:THandle;ControlFlags:dword;
  1953. lpdwBufferLength:LPDWORD;
  1954. lpqsResults:PWSAQUERYSET):longint;
  1955. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSALookupServiceNextA';
  1956. function WSAInstallServiceClass(lpServiceClassInfo:PWSASERVICECLASSINFO):longint;
  1957. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSAInstallServiceClassA';
  1958. function WSARemoveServiceClass(lpServiceClassId:PGUID):longint;
  1959. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSARemoveServiceClass';
  1960. function WSAGetServiceClassInfo(lpProviderId,lpServiceClassId:PGUID;
  1961. lpdwBufSize:LPDWORD;
  1962. lpServiceClassInfo:PWSASERVICECLASSINFO):longint;
  1963. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSAGetServiceClassInfoA';
  1964. function WSAGetServiceClassInfo(var ProviderId,ServiceClassId:TGUID;
  1965. var BufSize:DWORD;
  1966. var ServiceClassInfo:TWSASERVICECLASSINFO):longint;
  1967. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSAGetServiceClassInfoA';
  1968. function WSAEnumNameSpaceProviders(lpdwBufferLength:LPDWORD;lpnspBuffer:PWSANAMESPACE_INFO):longint;
  1969. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSAEnumNameSpaceProvidersA';
  1970. function WSAEnumNameSpaceProviders(var BufferLength:DWORD;var Buffer:TWSANAMESPACE_INFO):longint;
  1971. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSAEnumNameSpaceProvidersA';
  1972. function WSAGetServiceClassNameByClassId(lpServiceClassId:PGUID;lpszServiceClassName:pchar;buflen:PDWORD):longint;
  1973. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSAGetServiceClassNameByClassIdA';
  1974. function WSAGetServiceClassNameByClassId(var lpServiceClassId:TGUID;lpszServiceClassName:pchar;var buflen:DWORD):longint;
  1975. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSAGetServiceClassNameByClassIdA';
  1976. function WSASetService(lpqsRegInfo:PWSAQUERYSET;essoperation:TWSAESETSERVICEOP;flags:dword):longint;
  1977. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSASetServiceA';
  1978. {$ifndef Netware}
  1979. function WSAProviderConfigChange(lpNotificationHandle:LPHANDLE;
  1980. lpOverlapped:PWSAOVERLAPPED;
  1981. lpCompletionRoutine:TWSAOVERLAPPED_COMPLETION_ROUTINE):longint;
  1982. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSAProviderConfigChange';
  1983. {$endif}
  1984. implementation
  1985. { was #define dname(params) def_expr }
  1986. { argument types are unknown }
  1987. function MAKELONG(a,b : longint) : LONGINT;
  1988. begin
  1989. MAKELONG:=LONGINT((WORD(a)) or ((DWORD(WORD(b))) shl 16));
  1990. end;
  1991. function MAKEWORD(a,b : longint) : WORD;
  1992. begin
  1993. MAKEWORD:=WORD((BYTE(a)) or ((WORD(BYTE(b))) shl 8));
  1994. end;
  1995. {
  1996. Implementation of the helper routines
  1997. }
  1998. function WSAMakeSyncReply(Buflen,Error:Word):dword;
  1999. begin
  2000. WSAMakeSyncReply:=MakeLong(Buflen, Error);
  2001. end;
  2002. function WSAMakeSelectReply(Event,Error:Word):dword;
  2003. begin
  2004. WSAMakeSelectReply:=MakeLong(Event,Error);
  2005. end;
  2006. function WSAGetAsyncBuflen(Param:dword):Word;
  2007. begin
  2008. WSAGetAsyncBuflen:=lo(Param);
  2009. end;
  2010. function WSAGetAsyncError(Param:dword):Word;
  2011. begin
  2012. WSAGetAsyncError:=hi(Param);
  2013. end;
  2014. function WSAGetSelectEvent(Param:dword):Word;
  2015. begin
  2016. WSAGetSelectEvent:=lo(Param);
  2017. end;
  2018. function WSAGetSelectError(Param:dword):Word;
  2019. begin
  2020. WSAGetSelectError:=hi(Param);
  2021. end;
  2022. procedure FD_CLR(Socket:TSocket; var FDSet:TFDSet);
  2023. var
  2024. i : u_int;
  2025. begin
  2026. i:=0;
  2027. while i<FDSet.fd_count do
  2028. begin
  2029. if FDSet.fd_array[i]=Socket then
  2030. begin
  2031. while i<FDSet.fd_count-1 do
  2032. begin
  2033. FDSet.fd_array[i]:=FDSet.fd_array[i+1];
  2034. inc(i);
  2035. end;
  2036. dec(FDSet.fd_count);
  2037. break;
  2038. end;
  2039. inc(i);
  2040. end;
  2041. end;
  2042. {function FD_ISSET(Socket:TSocket; var FDSet:TFDSet):Boolean;
  2043. begin
  2044. FD_ISSET:=__WSAFDIsSet(Socket,FDSet);
  2045. end;}
  2046. procedure FD_SET(Socket:TSocket; var FDSet:TFDSet);
  2047. var i : integer;
  2048. begin
  2049. if FDSet.fd_count > FD_SETSIZE then
  2050. FDSet.fd_count := FD_SETSIZE;
  2051. for i := 1 to FDSet.fd_count do
  2052. if FDSet.fd_array[i-1] = Socket then exit; {this is what the c macro FD_SET does}
  2053. if FDSet.fd_count<FD_SETSIZE then
  2054. begin
  2055. FDSet.fd_array[FDSet.fd_count]:=Socket;
  2056. Inc(FDSet.fd_count);
  2057. end;
  2058. end;
  2059. procedure FD_ZERO(var FDSet:TFDSet);
  2060. var i : integer;
  2061. begin
  2062. for i := 0 to high (FDSet.fd_array) do
  2063. FDSet.fd_array[i] := INVALID_SOCKET;
  2064. FDSet.fd_count:=0;
  2065. end;
  2066. {$ifdef netware}
  2067. {windows has connect and accept in ws2_32.dll, netware has not, they
  2068. are defined as macros in ws2nlm.h }
  2069. function connect(s:TSocket; addr:PSockAddr; namelen:tOS_INT):tOS_INT;
  2070. begin
  2071. connect := WSAConnect (s,addr,namelen,nil,nil,nil,nil);
  2072. end;
  2073. function connect(s:TSocket; var name:TSockAddr; namelen:tOS_INT):tOS_INT; //cdecl;external winsockdll name 'WSAConnect';
  2074. begin
  2075. connect := WSAConnect (s,name,namelen,nil,nil,nil,nil);
  2076. end;
  2077. function accept(s:TSocket; addr: PSockAddr; addrlen : ptOS_INT) : TSocket;
  2078. begin
  2079. accept := WSAAccept (s,addr,addrlen,nil,0);
  2080. end;
  2081. function accept(s:TSocket; addr: PSockAddr; var addrlen : tOS_INT) : TSocket;
  2082. begin
  2083. accept := WSAAccept (s,addr,addrlen,nil,0);
  2084. end;
  2085. {$endif}
  2086. {AD 2003/03/25: Special for netware
  2087. if WSAStartup is called more than once, bad thinks will happen
  2088. on netware. This is not a problem under windows.
  2089. This happens with fcl because the unit initialization of SSockets and
  2090. resolve both calls WSAStartup, for the second startup we simply
  2091. return success without calling the WS2_32 WSAStartup }
  2092. function __WSAStartup(wVersionRequired:word;var WSAData:TWSADATA):tOS_INT;
  2093. {$ifdef Netware}cdecl;{$else}stdcall;{$endif}
  2094. external winsockdll name 'WSAStartup';
  2095. function __WSACleanup:tOS_INT;{$ifdef Netware}cdecl;{$else}stdcall;{$endif}external winsockdll name 'WSACleanup';
  2096. var WSAstartupData : TWSADATA;
  2097. function WSACleanup:tOS_INT;
  2098. begin
  2099. if WSAstartupData.wVersion <> $ffff then
  2100. begin
  2101. Result := __WSACleanup;
  2102. if Result = 0 then WSAstartupData.wVersion := $ffff;
  2103. end else Result := WSANOTINITIALISED;
  2104. end;
  2105. function WSAStartup(wVersionRequired:word;var WSAData:TWSADATA):tOS_INT;
  2106. begin
  2107. if WSAstartupData.wVersion = $ffff then
  2108. begin
  2109. Result := __WSAStartup(wVersionRequired,WSAData);
  2110. if Result = 0 then WSAstartupData := WSAData;
  2111. Writeln (stderr,'WSAStartup called');
  2112. end else
  2113. begin
  2114. result := 0;
  2115. Writeln (stderr,'WSAStartup should be called only once !');
  2116. end;
  2117. end;
  2118. initialization
  2119. WSAstartupData.wVersion := $ffff;
  2120. finalization
  2121. WSACleanUp;
  2122. end.
  2123. {
  2124. $Log$
  2125. Revision 1.3 2003-10-25 23:42:35 hajny
  2126. * THandle in sysutils common using System.THandle
  2127. Revision 1.2 2003/03/30 12:35:43 armin
  2128. * removed uses netware from winsock, DirectoryExists implemented
  2129. Revision 1.1 2003/03/25 18:17:54 armin
  2130. * support for fcl, support for linking without debug info
  2131. * renamed winsock2 to winsock for win32 compatinility
  2132. * new sockets unit for netware
  2133. * changes for compiler warnings
  2134. }