winsock.pp 89 KB

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