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