winsock.pp 87 KB

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