' api_winsock2.sbp 'Windows Sockets Ver2.0 #ifndef _INC_WINSOCK2 #define _INC_WINSOCK2 TypeDef SOCKET = ULONG_PTR Const SOCKET_ERROR = -1 Const INVALID_SOCKET = -1 'Port/socket numbers - network standard functions Const IPPORT_ECHO = 7 Const IPPORT_DISCARD = 9 Const IPPORT_SYSTAT = 11 Const IPPORT_DAYTIME = 13 Const IPPORT_NETSTAT = 15 Const IPPORT_FTP = 21 Const IPPORT_TELNET = 23 Const IPPORT_SMTP = 25 Const IPPORT_TIMESERVER = 37 Const IPPORT_NAMESERVER = 42 Const IPPORT_WHOIS = 43 Const IPPORT_MTP = 57 'Address families Const AF_UNSPEC = 0 Const AF_UNIX = 1 Const AF_INET = 2 Const AF_IMPLINK = 3 Const AF_PUP = 4 Const AF_CHAOS = 5 Const AF_NS = 6 Const AF_IPX = AF_NS Const AF_ISO = 7 Const AF_OSI = AF_ISO Const AF_ECMA = 8 Const AF_DATAKIT = 9 Const AF_CCITT = 10 Const AF_SNA = 11 Const AF_DECnet = 12 Const AF_DLI = 13 Const AF_LAT = 14 Const AF_HYLINK = 15 Const AF_APPLETALK = 16 Const AF_NETBIOS = 17 Const AF_VOICEVIEW = 18 Const AF_FIREFOX = 19 Const AF_UNKNOWN1 = 20 Const AF_BAN = 21 Const AF_ATM = 22 Const AF_INET6 = 23 Const AF_CLUSTER = 24 Const AF_12844 = 25 Const AF_MAX = 26 'Protocol families Const PF_UNSPEC = AF_UNSPEC Const PF_UNIX = AF_UNIX Const PF_INET = AF_INET Const PF_IMPLINK = AF_IMPLINK Const PF_PUP = AF_PUP Const PF_CHAOS = AF_CHAOS Const PF_NS = AF_NS Const PF_IPX = AF_IPX Const PF_ISO = AF_ISO Const PF_OSI = AF_OSI Const PF_ECMA = AF_ECMA Const PF_DATAKIT = AF_DATAKIT Const PF_CCITT = AF_CCITT Const PF_SNA = AF_SNA Const PF_DECnet = AF_DECnet Const PF_DLI = AF_DLI Const PF_LAT = AF_LAT Const PF_HYLINK = AF_HYLINK Const PF_APPLETALK = AF_APPLETALK Const PF_VOICEVIEW = AF_VOICEVIEW Const PF_FIREFOX = AF_FIREFOX Const PF_UNKNOWN1 = AF_UNKNOWN1 Const PF_BAN = AF_BAN Const PF_ATM = AF_ATM Const PF_INET6 = AF_INET6 Const PF_MAX = AF_MAX Const MSG_OOB = 1 'process out-of-band data Const MSG_PEEK = 2 'peek at incoming message Const MSG_DONTROUTE = 4 'send without using routing tables 'Error code Const WSABASEERR = 10000 Const WSAEINTR = WSABASEERR+4 Const WSAEBADF = WSABASEERR+9 Const WSAEACCES = WSABASEERR+13 Const WSAEFAULT = WSABASEERR+14 Const WSAEINVAL = WSABASEERR+22 Const WSAEMFILE = WSABASEERR+24 Const WSAEWOULDBLOCK = WSABASEERR+35 Const WSAEINPROGRESS = WSABASEERR+36 Const WSAEALREADY = WSABASEERR+37 Const WSAENOTSOCK = WSABASEERR+38 Const WSAEDESTADDRREQ = WSABASEERR+39 Const WSAEMSGSIZE = WSABASEERR+40 Const WSAEPROTOTYPE = WSABASEERR+41 Const WSAENOPROTOOPT = WSABASEERR+42 Const WSAEPROTONOSUPPORT = WSABASEERR+43 Const WSAESOCKTNOSUPPORT = WSABASEERR+44 Const WSAEOPNOTSUPP = WSABASEERR+45 Const WSAEPFNOSUPPORT = WSABASEERR+46 Const WSAEAFNOSUPPORT = WSABASEERR+47 Const WSAEADDRINUSE = WSABASEERR+48 Const WSAEADDRNOTAVAIL = WSABASEERR+49 Const WSAENETDOWN = WSABASEERR+50 Const WSAENETUNREACH = WSABASEERR+51 Const WSAENETRESET = WSABASEERR+52 Const WSAECONNABORTED = WSABASEERR+53 Const WSAECONNRESET = WSABASEERR+54 Const WSAENOBUFS = WSABASEERR+55 Const WSAEISCONN = WSABASEERR+56 Const WSAENOTCONN = WSABASEERR+57 Const WSAESHUTDOWN = WSABASEERR+58 Const WSAETOOMANYREFS = WSABASEERR+59 Const WSAETIMEDOUT = WSABASEERR+60 Const WSAECONNREFUSED = WSABASEERR+61 Const WSAELOOP = WSABASEERR+62 Const WSAENAMETOOLONG = WSABASEERR+63 Const WSAEHOSTDOWN = WSABASEERR+64 Const WSAEHOSTUNREACH = WSABASEERR+65 Const WSAENOTEMPTY = WSABASEERR+66 Const WSAEPROCLIM = WSABASEERR+67 Const WSAEUSERS = WSABASEERR+68 Const WSAEDQUOT = WSABASEERR+69 Const WSAESTALE = WSABASEERR+70 Const WSAEREMOTE = WSABASEERR+71 Const WSASYSNOTREADY = WSABASEERR+91 Const WSAVERNOTSUPPORTED = WSABASEERR+92 Const WSANOTINITIALISED = WSABASEERR+93 Const WSAEDISCON = WSABASEERR+101 Const WSAENOMORE = WSABASEERR+102 Const WSAECANCELLED = WSABASEERR+103 Const WSAEINVALIDPROCTABLE = WSABASEERR+104 Const WSAEINVALIDPROVIDER = WSABASEERR+105 Const WSAEPROVIDERFAILEDINIT =WSABASEERR+106 Const WSASYSCALLFAILURE = WSABASEERR+107 Const WSASERVICE_NOT_FOUND = WSABASEERR+108 Const WSATYPE_NOT_FOUND = WSABASEERR+109 Const WSA_E_NO_MORE = WSABASEERR+110 Const WSA_E_CANCELLED = WSABASEERR+111 Const WSAEREFUSED = WSABASEERR+112 '--------------- ' WinSock Types '--------------- Type HOSTENT h_name As BytePtr h_aliases As DWordPtr h_addrtype As Integer h_length As Integer h_addr_list As DWordPtr End Type Type SERVENT s_name As BytePtr s_aliases As DWordPtr s_port As Integer s_proto As BytePtr End Type Type SOCKADDR sa_family As Word sa_data[13] As Byte End Type Type SOCKADDR_IN sin_family As Word sin_port As Word sin_addr As DWord sin_zero[7] As Byte End Type '------------- ' WinSock API '------------- Declare Function closesocket Lib "ws2_32.dll" (s As SOCKET) As Long Declare Function connect Lib "ws2_32.dll" (s As SOCKET, ByRef name As Any, namelen As Long) As Long Declare Function gethostbyname Lib "ws2_32.dll" (name As BytePtr) As *HOSTENT Declare Function getservbyname Lib "ws2_32.dll" (name As BytePtr, proto As BytePtr) As *SERVENT Declare Function htonl Lib "ws2_32.dll" (hostlong As DWord) As DWord Declare Function htons Lib "ws2_32.dll" (hostshort As Word) As Word Declare Function recv Lib "ws2_32.dll" (s As SOCKET, buf As BytePtr, length As Long, flags As Long) As Long Declare Function send Lib "ws2_32.dll" (s As SOCKET, buf As BytePtr, length As Long, flags As Long) As Long Const SD_RECEIVE = 0 Const SD_SEND = 1 Const SD_BOTH = 2 Declare Function shutdown Lib "ws2_32.dll" (s As SOCKET, how As Long) As Long Const SOCK_STREAM = 1 Const SOCK_DGRAM = 2 Const SOCK_RAW = 3 Const SOCK_RDM = 4 Const SOCK_SEQPACKET = 5 Declare Function socket Lib "ws2_32.dll" (af As Long, sokettype As Long, protocol As Long) As SOCKET Declare Function WSACleanup Lib "ws2_32.dll" () As Integer Const WSADESCRIPTION_LEN = 256 Const WSASYS_STATUS_LEN = 128 Type WSADATA wVersion As Word wHighVersion As Word szDescription[WSADESCRIPTION_LEN] As Byte szSystemStatus[WSASYS_STATUS_LEN] As Byte iMaxSockets As Word iMaxUdpDg As Word lpVendorInfo As BytePtr End Type Declare Function WSAStartup Lib "ws2_32.dll" (wVersionRequested As Word, ByRef lpWSAData As WSADATA) As Long Declare Function accept Lib "ws2_32.dll" (s As SOCKET, ByRef addr As SOCKADDR_IN, ByVal addrlen As Long) As SOCKET Declare Function bind Lib "ws2_32.dll" (s As SOCKET, ByRef sName As SOCKADDR_IN, ByVal namelen As Long) As Long Declare Function ioctlsocket Lib "ws2_32.dll" (s As SOCKET, ByVal cmd As Long, argp As DWord) As Long Declare Function listen Lib "ws2_32.dll" (s As SOCKET, ByVal backlog As Long) As Long Declare Function recvfrom Lib "ws2_32.dll" (s As SOCKET, buf As BytePtr, length As Long, flags As Long, ByRef from As SOCKADDR_IN, fromlen As Long) As Long Declare Function sendto Lib "ws2_32.dll" (s As SOCKET, buf As BytePtr, length As Long, flags As Long, ByRef sTo As SOCKADDR_IN, tolen As Long) As Long Const INADDR_ANY = &h0 #endif '_INC_WINSOCK2