home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1999 April / CD_Shareware_Magazine_31.iso / Free / Prg / ftpcl.exe / WINSOCK.BAS < prev   
Encoding:
BASIC Source File  |  1995-05-01  |  21.2 KB  |  504 lines

  1. 'This is the Winsock API definition file for Visual Basic
  2. 'The file is a port from the C header file found in the
  3. 'Winsock Version 1.1 API specification.
  4.  
  5. Global Const FD_SETSIZE% = 64
  6.  
  7. Type FD_SET
  8.   fd_count As Integer
  9.   fd_array(FD_SETSIZE) As Integer
  10. End Type 'fd_set
  11. Global Const SZFD_SET = 4
  12.  
  13. Declare Function FD_ISSET Lib "winsock.dll" Alias "#151" (ByVal s As Integer, passed_set As FD_SET) As Integer
  14. Declare Function x_WSAFDIsSet Lib "winsock.dll" Alias "#151" (ByVal s As Integer, passed_set As FD_SET) As Integer
  15.  
  16. Type timeval
  17.   tv_sec As Long
  18.   tv_usec As Long
  19. End Type
  20. Global Const SZTIMEVAL = 8
  21.  
  22. 'Setup the variable type 'hostent' for the WSAStartup command
  23. Type Hostent
  24.   h_name As Long
  25.   h_aliases As Long
  26.   h_addrtype As String * 2
  27.   h_length As String * 2
  28.   h_addr_list As Long
  29. End Type
  30. Global Const SZHOSTENT = 16
  31.  
  32.  
  33. 'This section lists the protocol ID's as theu
  34. 'are registered with the IANA
  35. 'Check RFC1117 for more details
  36. Global Const IPPROTO_IP% = 0                 ' dummy for IP
  37. Global Const IPPROTO_ICMP% = 1               ' control message protocol
  38. Global Const IPPROTO_GGP% = 2                ' gateway^2 (deprecated)
  39. Global Const IPPROTO_TCP% = 6                ' tcp
  40. Global Const IPPROTO_PUP% = 12               ' pup
  41. Global Const IPPROTO_UDP% = 17               ' user datagram protocol
  42. Global Const IPPROTO_IDP% = 22               ' xns idp
  43. Global Const IPPROTO_ND% = 77                ' UNOFFICIAL net disk proto
  44.  
  45. Global Const IPPROTO_RAW% = 255              ' raw IP packet
  46. Global Const IPPROTO_MAX% = 256
  47.  
  48. 'Port numbers for network services
  49. 'Check STD2 for more details
  50. Global Const IPPORT_ECHO% = 7
  51. Global Const IPPORT_SYSTAT% = 11
  52. Global Const IPPORT_DAYTIME% = 13
  53. Global Const IPPORT_FTP% = 21
  54. Global Const IPPORT_TELNET% = 23
  55. Global Const IPPORT_SMTP% = 25
  56. Global Const IPPORT_FINGER% = 79
  57. 'Set the restricted port floor to 1024 for experimental operations
  58. Global Const IPPORT_RESERVED% = 1024
  59.  
  60. 'Set the Internet address type to a long integer (32-bit)
  61. Type in_addr
  62.  s_addr As Long
  63. End Type
  64.  
  65. 'Set Internet address classes (A,B,C)
  66. Global Const IN_CLASSA_NET& = &HFF000000
  67. Global Const IN_CLASSA_NSHIFT& = 24
  68. Global Const IN_CLASSA_HOST& = &HFFFFFF
  69. Global Const IN_CLASSA_MAX& = 128
  70.  
  71. Global Const IN_CLASSB_NET& = &HFFFF0000
  72. Global Const IN_CLASSB_NSHIFT& = 16
  73. Global Const IN_CLASSB_HOST& = &HFFFF
  74. Global Const IN_CLASSB_MAX& = 65536
  75.  
  76. Global Const IN_CLASSC_NET& = &HFFFFFF00
  77. Global Const IN_CLASSC_NSHIFT& = 8
  78. Global Const IN_CLASSC_HOST& = &HFF
  79.  
  80. Global Const INADDR_ANY& = &H0
  81. Global Const INADDR_LOOPBACK& = &H7F000001
  82. Global Const INADDR_BROADCAST& = &HFFFFFFFF
  83. Global Const INADDR_NONE& = &HFFFFFFFF
  84.  
  85.  'A note to those familiar with the C header file for Winsock
  86. 'Visual Basic does not permit a user-defined variable type
  87. 'to be used as a return structure.  In the case of the
  88. 'variable definition below, sin_addr must
  89. 'be declared as a long integer rather than the user-defined
  90. 'variable type of in_addr.
  91. Type sockaddr_in
  92.   sin_family As Integer
  93.   sin_port As Integer
  94.   sin_addr As Long
  95.   sin_zero As String * 8
  96. End Type
  97.  
  98. Global Const WSADESCRIPTION_LEN% = 256
  99. Global Const WSASYS_STATUS_LEN% = 128
  100.  
  101. 'Setup the structure for the information returned from
  102. 'the WSAStartup() function.
  103. Type WSAData
  104.    wVersion As Integer
  105.    wHighVersion As Integer
  106.    szDescription As String * 257
  107.    szSystemStatus As String * 129
  108.    iMaxSockets As Integer
  109.    iMaxUdpDg As Integer
  110.    lpVendorInfo As String * 200
  111. End Type
  112.  
  113. 'Define socket return codes
  114. Global Const INVALID_SOCKET% = &HFFFF
  115. Global Const SOCKET_ERROR% = -1
  116.  
  117. 'Define socket types
  118. Global Const SOCK_STREAM% = 1   'Stream socket
  119. Global Const SOCK_DGRAM% = 2    'Datagram socket
  120. Global Const SOCK_RAW% = 3              'Raw data socket
  121. Global Const SOCK_RDM% = 4              'Reliable Delivery socket
  122. Global Const SOCK_SEQPACKET% = 5        'Sequenced Packet socket
  123.  
  124.  
  125. 'Socket option flags
  126. Global Const SO_DEBUG% = &H1                    ' turn on debugging info recording
  127. Global Const SO_ACCEPTCONN% = &H2               ' socket has had listen()
  128. Global Const SO_REUSEADDR% = &H4                ' allow local address reuse
  129. Global Const SO_KEEPALIVE% = &H8                ' keep connections alive
  130. Global Const SO_DONTROUTE% = &H10               ' just use interface addresses
  131. Global Const SO_BROADCAST% = &H20               ' permit sending of broadcast msgs
  132. Global Const SO_USELOOPBACK% = &H40             ' bypass hardware when possible
  133. Global Const SO_LINGER% = &H80                  ' linger on close if data present
  134. Global Const SO_OOBINLINE% = &H100              ' leave received OOB data in line
  135. Global Const SO_DONTLINGER% = &HFF7F            ' same as SO_LINGER
  136. Global Const SO_SNDBUF% = &H1001                ' send buffer size
  137. Global Const SO_RCVBUF% = &H1002                        ' receive buffer size
  138. Global Const SO_SNDLOWAT% = &H1003             ' send low-water mark
  139. Global Const SO_RCVLOWAT% = &H1004             ' receive low-water mark
  140. Global Const SO_SNDTIMEO% = &H1005                      ' send timeout
  141. Global Const SO_RCVTIMEO% = &H1006              ' receive timeout
  142. Global Const SO_ERROR% = &H1007                         ' get error status and clear
  143. Global Const SO_TYPE% = &H1008                          ' get socket type
  144.  
  145.  
  146. 'Define TCP option flag
  147. Global Const TCP_NODELAY% = &H1
  148.  
  149.  
  150. 'Define address families
  151. Global Const AF_UNSPEC% = 0                             ' unspecified
  152. Global Const AF_UNIX% = 1                               ' local to host (pipes, portals)
  153. Global Const AF_INET% = 2                                       ' internetwork: UDP, TCP, etc.
  154. Global Const AF_IMPLINK% = 3                            ' arpanet imp addresses
  155. Global Const AF_PUP% = 4                                        ' pup protocols: e.g. BSP
  156. Global Const AF_CHAOS% = 5                              ' mit CHAOS protocols
  157. Global Const AF_NS% = 6                                         ' XEROX NS protocols
  158. Global Const AF_ISO% = 7                                        ' ISO protocols
  159. Global Const AF_OSI% = AF_ISO                           ' OSI is ISO
  160. Global Const AF_ECMA% = 8                               ' european computer manufacturers
  161. Global Const AF_DATAKIT% = 9                            ' datakit protocols
  162. Global Const AF_CCITT% = 10                             ' CCITT protocols, X.25 etc
  163. Global Const AF_SNA% = 11                               ' IBM SNA
  164. Global Const AF_DECnet% = 12                            ' DECnet
  165. Global Const AF_DLI% = 13                                       ' Direct data link interface
  166. Global Const AF_LAT% = 14                                       ' LAT
  167. Global Const AF_HYLINK% = 15                            ' NSC Hyperchannel
  168. Global Const AF_APPLETALK% = 16                         ' AppleTalk
  169. Global Const AF_NETBIOS% = 17                           ' NetBios-style addresses
  170. Global Const AF_MAX% = 18                       'Maximum # of address families
  171.  
  172.  
  173. 'Setup sockaddr data type to store Internet addresses
  174. Type sockaddr
  175.   sa_family As Integer
  176.   sa_data As String * 14
  177. End Type
  178. Global Const SADDRLEN% = 16
  179.  
  180.  
  181. 'Setup sockproto type used for socket information
  182. Type sockproto
  183.   sp_family As Integer
  184.   sp_protocol As Integer
  185. End Type
  186.  
  187.  
  188. 'Define Protocol families...the same as address families
  189. Global Const PF_UNSPEC% = AF_UNSPEC
  190. Global Const PF_UNIX% = AF_UNIX
  191. Global Const PF_INET% = AF_INET
  192. Global Const PF_IMPLINK% = AF_IMPLINK
  193. Global Const PF_PUP% = AF_PUP
  194. Global Const PF_CHAOS% = AF_CHAOS
  195. Global Const PF_NS% = AF_NS
  196. Global Const PF_ISO% = AF_ISO
  197. Global Const PF_OSI% = AF_OSI
  198. Global Const PF_ECMA% = AF_ECMA
  199. Global Const PF_DATAKIT% = AF_DATAKIT
  200. Global Const PF_CCITT% = AF_CCITT
  201. Global Const PF_SNA% = AF_SNA
  202. Global Const PF_DECnet% = AF_DECnet
  203. Global Const PF_DLI% = AF_DLI
  204. Global Const PF_LAT% = AF_LAT
  205. Global Const PF_HYLINK% = AF_HYLINK
  206. Global Const PF_APPLETALK% = AF_APPLETALK
  207. Global Const PF_MAX% = AF_MAX
  208.  
  209. 'Setup data type used for manipulating linger option.
  210. Type linger
  211.   l_onoff As Integer
  212.   l_linger As Integer
  213. End Type
  214.  
  215. 'Define level number for (get/set)sockopt() to apply to socket itself.
  216. Global Const SOL_SOCKET% = &HFFFF
  217.  
  218. 'Define maximum queue length specifiable by listen().
  219. Global Const SOMAXCONN% = 5             ' maximum # of queued connections
  220. Global Const MSG_OOB% = &H1                     ' process out-of-band data
  221. Global Const MSG_PEEK% = &H2                    ' peek at incoming message
  222. Global Const MSG_DONTROUTE% = &H4               ' send without using routing tables
  223. Global Const MSG_MAXIOVLEN% = 16
  224.  
  225. 'Define constant based on rfc883, used by gethostby....() calls.
  226. Global Const MAXGETHOSTSTRUCT% = 1024
  227.  
  228. 'Define flags to be used with the WSAAsyncSelect() call.
  229. Global Const FD_READ% = &H1
  230. Global Const FD_WRITE% = &H2
  231. Global Const FD_OOB% = &H4
  232. Global Const FD_ACCEPT% = &H8
  233. Global Const FD_CONNECT% = &H10
  234. Global Const FD_CLOSE% = &H20
  235.  
  236.  
  237.  
  238. 'All Windows Sockets error constants are biased by WSABASEERR from
  239. 'the "normal"
  240. Global Const WSABASEERR% = 10000
  241.  
  242. 'Define Windows Sockets definitions of regular Microsoft C error constants
  243. Global Const WSAEINTR% = (WSABASEERR + 4)
  244. Global Const WSAEBADF% = (WSABASEERR + 9)
  245. Global Const WSAEACCES% = (WSABASEERR + 13)
  246. Global Const WSAEFAULT% = (WSABASEERR + 14)
  247. Global Const WSAEINVAL% = (WSABASEERR + 22)
  248. Global Const WSAEMFILE% = (WSABASEERR + 24)
  249.  
  250. 'Define Windows Sockets definitions of error constants
  251. Global Const WSAEWOULDBLOCK% = (WSABASEERR + 35)
  252. Global Const WSAEINPROGRESS% = (WSABASEERR + 36)
  253. Global Const WSAEALREADY% = (WSABASEERR + 37)
  254. Global Const WSAENOTSOCK% = (WSABASEERR + 38)
  255. Global Const WSAEDESTADDRREQ% = (WSABASEERR + 39)
  256. Global Const WSAEMSGSIZE% = (WSABASEERR + 40)
  257. Global Const WSAEPROTOTYPE% = (WSABASEERR + 41)
  258. Global Const WSAENOPROTOOPT% = (WSABASEERR + 42)
  259. Global Const WSAEPROTONOSUPPORT% = (WSABASEERR + 43)
  260. Global Const WSAESOCKTNOSUPPORT% = (WSABASEERR + 44)
  261. Global Const WSAEOPNOTSUPP% = (WSABASEERR + 45)
  262. Global Const WSAEPFNOSUPPORT% = (WSABASEERR + 46)
  263. Global Const WSAEAFNOSUPPORT% = (WSABASEERR + 47)
  264. Global Const WSAEADDRINUSE% = (WSABASEERR + 48)
  265. Global Const WSAEADDRNOTAVAIL% = (WSABASEERR + 49)
  266. Global Const WSAENETDOWN% = (WSABASEERR + 50)
  267. Global Const WSAENETUNREACH% = (WSABASEERR + 51)
  268. Global Const WSAENETRESET% = (WSABASEERR + 52)
  269. Global Const WSAECONNABORTED% = (WSABASEERR + 53)
  270. Global Const WSAECONNRESET% = (WSABASEERR + 54)
  271. Global Const WSAENOBUFS% = (WSABASEERR + 55)
  272. Global Const WSAEISCONN% = (WSABASEERR + 56)
  273. Global Const WSAENOTCONN% = (WSABASEERR + 57)
  274. Global Const WSAESHUTDOWN% = (WSABASEERR + 58)
  275. Global Const WSAETOOMANYREFS% = (WSABASEERR + 59)
  276. Global Const WSAETIMEDOUT% = (WSABASEERR + 60)
  277. Global Const WSAECONNREFUSED% = (WSABASEERR + 61)
  278. Global Const WSAELOOP% = (WSABASEERR + 62)
  279. Global Const WSAENAMETOOLONG% = (WSABASEERR + 63)
  280. Global Const WSAEHOSTDOWN% = (WSABASEERR + 64)
  281. Global Const WSAEHOSTUNREACH% = (WSABASEERR + 65)
  282. Global Const WSAENOTEMPTY% = (WSABASEERR + 66)
  283. Global Const WSAEPROCLIM% = (WSABASEERR + 67)
  284. Global Const WSAEUSERS% = (WSABASEERR + 68)
  285. Global Const WSAEDQUOT% = (WSABASEERR + 69)
  286. Global Const WSAESTALE% = (WSABASEERR + 70)
  287. Global Const WSAEREMOTE% = (WSABASEERR + 71)
  288.  
  289. 'Define Extended Windows Sockets error constant definitions
  290. Global Const WSASYSNOTREADY% = (WSABASEERR + 91)
  291. Global Const WSAVERNOTSUPPORTED% = (WSABASEERR + 92)
  292. Global Const WSANOTINITIALISED% = (WSABASEERR + 93)
  293.  
  294. 'Define error return codes from gethostbyname() and gethostbyaddr()
  295.  
  296. ' Authoritative Answer: Host not found
  297. Global Const WSAHOST_NOT_FOUND% = (WSABASEERR + 1001)
  298. Global Const HOST_NOT_FOUND% = WSAHOST_NOT_FOUND
  299.  
  300. ' Non-Authoritative: Host not found, or SERVERFAIL
  301. Global Const WSATRY_AGAIN% = (WSABASEERR + 1002)
  302. Global Const TRY_AGAIN% = WSATRY_AGAIN
  303.  
  304. ' Non recoverable errors, FORMERR, REFUSED, NOTIMP
  305. Global Const WSANO_RECOVERY% = (WSABASEERR + 1003)
  306. Global Const NO_RECOVERY% = WSANO_RECOVERY
  307.  
  308. ' Valid name, no data record of requested type
  309. Global Const WSANO_DATA% = (WSABASEERR + 1004)
  310. Global Const NO_DATA% = WSANO_DATA
  311.  
  312. ' no address, look for MX record
  313. Global Const WSANO_ADDRESS% = WSANO_DATA
  314. Global Const NO_ADDRESS% = WSANO_ADDRESS
  315.  
  316. 'Define Windows Sockets errors redefined as error constants
  317. Global Const EWOULDBLOCK% = WSAEWOULDBLOCK
  318. Global Const EINPROGRESS% = WSAEINPROGRESS
  319. Global Const EALREADY% = WSAEALREADY
  320. Global Const ENOTSOCK% = WSAENOTSOCK
  321. Global Const EDESTADDRREQ% = WSAEDESTADDRREQ
  322. Global Const EMSGSIZE% = WSAEMSGSIZE
  323. Global Const EPROTOTYPE% = WSAEPROTOTYPE
  324. Global Const ENOPROTOOPT% = WSAENOPROTOOPT
  325. Global Const EPROTONOSUPPORT% = WSAEPROTONOSUPPORT
  326. Global Const ESOCKTNOSUPPORT% = WSAESOCKTNOSUPPORT
  327. Global Const EOPNOTSUPP% = WSAEOPNOTSUPP
  328. Global Const EPFNOSUPPORT% = WSAEPFNOSUPPORT
  329. Global Const EAFNOSUPPORT% = WSAEAFNOSUPPORT
  330. Global Const EADDRINUSE% = WSAEADDRINUSE
  331. Global Const EADDRNOTAVAIL% = WSAEADDRNOTAVAIL
  332. Global Const ENETDOWN% = WSAENETDOWN
  333. Global Const ENETUNREACH% = WSAENETUNREACH
  334. Global Const ENETRESET% = WSAENETRESET
  335. Global Const ECONNABORTED% = WSAECONNABORTED
  336. Global Const ECONNRESET% = WSAECONNRESET
  337. Global Const ENOBUFS% = WSAENOBUFS
  338. Global Const EISCONN% = WSAEISCONN
  339. Global Const ENOTCONN% = WSAENOTCONN
  340. Global Const ESHUTDOWN% = WSAESHUTDOWN
  341. Global Const ETOOMANYREFS% = WSAETOOMANYREFS
  342. Global Const ETIMEDOUT% = WSAETIMEDOUT
  343. Global Const ECONNREFUSED% = WSAECONNREFUSED
  344. Global Const ELOOP% = WSAELOOP
  345. Global Const ENAMETOOLONG% = WSAENAMETOOLONG
  346. Global Const EHOSTDOWN% = WSAEHOSTDOWN
  347. Global Const EHOSTUNREACH% = WSAEHOSTUNREACH
  348. Global Const ENOTEMPTY% = WSAENOTEMPTY
  349. Global Const EPROCLIM% = WSAEPROCLIM
  350. Global Const EUSERS% = WSAEUSERS
  351. Global Const EDQUOT% = WSAEDQUOT
  352. Global Const ESTALE% = WSAESTALE
  353. Global Const EREMOTE% = WSAEREMOTE
  354.  
  355. 'Declare Socket functions
  356.  
  357. Declare Function accept% Lib "winsock.dll" Alias "#1" (ByVal s As Integer, addr As sockaddr, ByVal namelen As Integer)
  358.  
  359. Declare Function bind% Lib "winsock.dll" Alias "#2" (ByVal s As Integer, addr As sockaddr_in, ByVal namelen As Integer)
  360.  
  361. Declare Function closesocket% Lib "winsock.dll" Alias "#3" (ByVal s As Integer)
  362.  
  363. Declare Function connect% Lib "winsock.dll" Alias "#4" (ByVal s As Integer, addr As sockaddr_in, ByVal namelen As Integer)
  364.  
  365. Declare Function ioctlsocket% Lib "winsock.dll" Alias "#12" (ByVal s As Integer, ByVal cmd As Long, argp As Long)
  366.  
  367. Declare Function getpeername% Lib "winsock.dll" Alias "#5" (ByVal s As Integer, peername As sockaddr_in, namelen As Integer)
  368.  
  369. Declare Function getsockname% Lib "winsock.dll" Alias "#6" (ByVal s As Integer, sockname As sockaddr_in, namelen As Integer)
  370.  
  371. Declare Function getsockopt% Lib "winsock.dll" Alias "#7" (ByVal s As Integer, ByVal level As Integer, ByVal optname As Integer, ByVal optval As String, optlen As Integer)
  372.  
  373. Declare Function htonl& Lib "winsock.dll" Alias "#8" (ByVal hostlong As Long)
  374.  
  375. Declare Function htons% Lib "winsock.dll" Alias "#9" (ByVal hostshort As Integer)
  376.  
  377. Declare Function inet_addr& Lib "winsock.dll" Alias "#10" (ByVal cp As String)
  378.  
  379. Declare Function inet_ntoa& Lib "winsock.dll" Alias "#11" (ByVal in As Long)
  380.  
  381. Declare Function listen& Lib "winsock.dll" Alias "#12" (ByVal s As Integer, ByVal backlog As Integer)
  382.  
  383. Declare Function ntohl& Lib "winsock.dll" Alias "#14" (ByVal netlong As Long)
  384.  
  385. Declare Function ntohs% Lib "winsock.dll" Alias "#15" (ByVal netshort As Integer)
  386.  
  387. Declare Function recv% Lib "winsock.dll" Alias "#16" (ByVal s As Integer, ByVal buf As String, ByVal buflen As Integer, ByVal flags As Integer)
  388.  
  389. Declare Function recvfrom% Lib "winsock.dll" Alias "#17" (ByVal s As Integer, ByVal buf As String, ByVal buflen As Integer, ByVal flags As Integer, fromaddr As sockaddr_in, fromlen As Integer)
  390.  
  391. ' Visual Basic note...since select is a keyword in Visual Basic the function has been renamed
  392. Declare Function WSASelect% Lib "winsock.dll" Alias "#18" (ByVal nfds As Integer, readfds As FD_SET, writefds As FD_SET, exceptfds As FD_SET, timeout As timeval)
  393.  
  394. Declare Function send% Lib "winsock.dll" Alias "#19" (ByVal s As Integer, ByVal buf As String, ByVal buflen As Integer, ByVal flags As Integer)
  395.  
  396. Declare Function sendto% Lib "winsock.dll" Alias "#20" (ByVal s As Integer, ByVal buf As String, ByVal buflen As Integer, ByVal flags As Integer, toaddr As sockaddr_in, ByVal tolen As Integer)
  397.  
  398. Declare Function setsockopt% Lib "winsock.dll" Alias "#21" (ByVal s As Integer, ByVal level As Integer, ByVal optname As Integer, optval As Long, ByVal optlen As Integer)
  399.  
  400. Declare Function shutdown% Lib "winsock.dll" Alias "#22" (ByVal s As Integer, ByVal how As Integer)
  401.  
  402. Declare Function socket% Lib "winsock.dll" Alias "#23" (ByVal af As Integer, ByVal socktype As Integer, ByVal protocol As Integer)
  403.  
  404. Declare Function gethostbyaddr& Lib "winsock.dll" Alias "#51" (addr As Long, ByVal addrlen As Integer, ByVal addrtype As Integer)
  405.  
  406. Declare Function GetHostByName& Lib "winsock.dll" Alias "#52" (ByVal hostname As String)
  407.  
  408. Declare Function GetHostName% Lib "winsock.dll" Alias "#57" (ByVal hostname As Long, ByVal namelen As Integer)
  409.  
  410. Declare Function getservbyport& Lib "winsock.dll" Alias "#56" (ByVal port As Integer, ByVal protoname As Long)
  411.  
  412. Declare Function getservbyname& Lib "winsock.dll" Alias "#55" (ByVal servname As Long, ByVal protoname As Long)
  413.  
  414. Declare Function getprotobynumber& Lib "winsock.dll" Alias "#54" (ByVal protonumber As Integer)
  415.  
  416. Declare Function getprotobyname& Lib "winsock.dll" Alias "#53" (ByVal protoname As String)
  417.  
  418. Declare Function WSAStartup% Lib "winsock.dll" Alias "#115" (ByVal wVersionRequired As Integer, lpWSAData As WSAData)
  419.  
  420. Declare Function WSACleanUp% Lib "winsock.dll" Alias "#116" ()
  421.  
  422. Declare Function WSASetLastError% Lib "winsock.dll" Alias "#112" (ByVal iError As Integer)
  423.  
  424. Declare Function WSAGetLastError% Lib "winsock.dll" Alias "#111" ()
  425.  
  426. Declare Function WSAIsBlocking% Lib "winsock.dll" Alias "#114" ()
  427.  
  428. Declare Function WSAUnhookBlockingHook% Lib "winsock.dll" Alias "#110" ()
  429.  
  430. Declare Function WSASetBlockingHook& Lib "winsock.dll" Alias "#109" (lpFunc As Long)
  431.  
  432. Declare Function WSACancelBlockingCall% Lib "winsock.dll" Alias "#113" ()
  433.  
  434. Declare Function WSAAsyncGetServByName% Lib "winsock.dll" Alias "#107" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal hostname As String, ByVal proto As String, ByVal buf As String, ByVal buflen As Integer)
  435.  
  436. Declare Function WSAAsyncGetServByPort% Lib "winsock.dll" Alias "#106" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal port As Integer, ByVal proto As String, ByVal buf As String, ByVal buflen As Integer)
  437.  
  438. Declare Function WSAAsyncGetProtoByName% Lib "winsock.dll" Alias "#105" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal protoname As String, ByVal buf As String, ByVal buflen As Integer)
  439.  
  440. Declare Function WSAAsyncGetProtoByNumber% Lib "winsock.dll" Alias "#104" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal number As Integer, ByVal buf As String, ByVal buflen As Integer)
  441.  
  442. Declare Function WSAAsyncGetHostByName% Lib "winsock.dll" Alias "#103" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal hostname As String, ByVal buf As String, ByVal buflen As Integer)
  443.  
  444. Declare Function WSAAsyncGetHostByAddr% Lib "winsock.dll" Alias "#102" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal addr As String, ByVal addrlen As Integer, ByVal addrtype As Integer, ByVal buf As String, ByVal buflen As Integer)
  445.  
  446. Declare Function WSACancelAsyncRequest% Lib "winsock.dll" Alias "#108" (ByVal hAsyncTaskHandle As Integer)
  447.  
  448. Declare Function WSAAsyncSelect% Lib "winsock.dll" Alias "#101" (ByVal s As Integer, ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal lEvent As Long)
  449.  
  450. 'Winsock Subroutines as described in the Winsock standard
  451.  
  452. Declare Function GetHostAddressByName Lib "hostname.dll" Alias "GETHOSTADDRESSFROMNAME" (ByVal yourhostname As String) As Long
  453.  
  454. Sub FD_CLR (ByVal fd As Integer, fdset As FD_SET)
  455.     '--------------------
  456.     ' remove fd from set
  457.     '--------------------
  458.     Dim i As Integer
  459.     For i = 0 To (fdset.fd_count) - 1                   'loop thru entries
  460.     If fdset.fd_array(i) = fd Then          ' if match found
  461.         Dim j As Integer
  462.         fdset.fd_count = (fdset.fd_count) - 1' reduce count
  463.         While j < fdset.fd_count            ' move others up in array
  464.         fdset.fd_array(j) = fdset.fd_array(j + 1)
  465.         Wend
  466.     End If
  467.     Next i
  468. End Sub
  469.  
  470. Sub FD_SET (ByVal fd As Integer, fdset As FD_SET)
  471.     '---------------
  472.     ' add fd to set
  473.     '---------------
  474.     If fdset.fd_count < FD_SETSIZE Then
  475.     fdset.fd_array(fdset.fd_count) = fd             'put entry in last
  476.     fdset.fd_count = (fdset.fd_count) + 1           'increment count
  477.     End If
  478. End Sub
  479.  
  480. Sub FD_ZERO (fdset As FD_SET)
  481.     fdset.fd_count = 0                          'set count to zero
  482. End Sub
  483.  
  484. Function WSA_VERSION (MajorVer As Integer, MinorVer As Integer) As Integer
  485.     WSA_VERSION = (MinorVer * 256) + MajorVer
  486. End Function
  487.  
  488. Function WSAGetASYNCBUFLEN (lParam As Integer) As Integer
  489.     WSAGetASYNCBUFLEN = lParam And &HFF
  490. End Function
  491.  
  492. Function WSAGETASYNCERROR (lParam As Integer) As Integer
  493.     WSAGETASYNCERROR = (lParam And &HFF00) ^ -8 'Shift Right 8 Places
  494. End Function
  495.  
  496. Function WSAGETSELECTERROR (lParam As Integer) As Integer
  497.     WSAGETSELECTERROR = (lParam And &HFF00) ^ -8
  498. End Function
  499.  
  500. Function WSAGETSELECTEVENT (lParam As Integer) As Integer
  501.     WSAGETSELECTEVENT = lParam And &HFF
  502. End Function
  503.  
  504.