source: Include/api_winsock2.sbp@ 24

Last change on this file since 24 was 24, checked in by イグトランス (egtra), 17 years ago

Add endian conversion functions

File size: 8.1 KB
Line 
1' api_winsock2.sbp
2'Windows Sockets Ver2.0
3
4
5#ifndef _INC_WINSOCK2
6#define _INC_WINSOCK2
7
8TypeDef SOCKET = ULONG_PTR
9
10Const SOCKET_ERROR = -1
11Const INVALID_SOCKET = -1
12
13
14'Port/socket numbers - network standard functions
15Const IPPORT_ECHO = 7
16Const IPPORT_DISCARD = 9
17Const IPPORT_SYSTAT = 11
18Const IPPORT_DAYTIME = 13
19Const IPPORT_NETSTAT = 15
20Const IPPORT_FTP = 21
21Const IPPORT_TELNET = 23
22Const IPPORT_SMTP = 25
23Const IPPORT_TIMESERVER = 37
24Const IPPORT_NAMESERVER = 42
25Const IPPORT_WHOIS = 43
26Const IPPORT_MTP = 57
27
28
29'Address families
30Const AF_UNSPEC = 0
31Const AF_UNIX = 1
32Const AF_INET = 2
33Const AF_IMPLINK = 3
34Const AF_PUP = 4
35Const AF_CHAOS = 5
36Const AF_NS = 6
37Const AF_IPX = AF_NS
38Const AF_ISO = 7
39Const AF_OSI = AF_ISO
40Const AF_ECMA = 8
41Const AF_DATAKIT = 9
42Const AF_CCITT = 10
43Const AF_SNA = 11
44Const AF_DECnet = 12
45Const AF_DLI = 13
46Const AF_LAT = 14
47Const AF_HYLINK = 15
48Const AF_APPLETALK = 16
49Const AF_NETBIOS = 17
50Const AF_VOICEVIEW = 18
51Const AF_FIREFOX = 19
52Const AF_UNKNOWN1 = 20
53Const AF_BAN = 21
54Const AF_ATM = 22
55Const AF_INET6 = 23
56Const AF_CLUSTER = 24
57Const AF_12844 = 25
58Const AF_MAX = 26
59
60
61'Protocol families
62Const PF_UNSPEC = AF_UNSPEC
63Const PF_UNIX = AF_UNIX
64Const PF_INET = AF_INET
65Const PF_IMPLINK = AF_IMPLINK
66Const PF_PUP = AF_PUP
67Const PF_CHAOS = AF_CHAOS
68Const PF_NS = AF_NS
69Const PF_IPX = AF_IPX
70Const PF_ISO = AF_ISO
71Const PF_OSI = AF_OSI
72Const PF_ECMA = AF_ECMA
73Const PF_DATAKIT = AF_DATAKIT
74Const PF_CCITT = AF_CCITT
75Const PF_SNA = AF_SNA
76Const PF_DECnet = AF_DECnet
77Const PF_DLI = AF_DLI
78Const PF_LAT = AF_LAT
79Const PF_HYLINK = AF_HYLINK
80Const PF_APPLETALK = AF_APPLETALK
81Const PF_VOICEVIEW = AF_VOICEVIEW
82Const PF_FIREFOX = AF_FIREFOX
83Const PF_UNKNOWN1 = AF_UNKNOWN1
84Const PF_BAN = AF_BAN
85Const PF_ATM = AF_ATM
86Const PF_INET6 = AF_INET6
87Const PF_MAX = AF_MAX
88
89
90Const MSG_OOB = 1 'process out-of-band data
91Const MSG_PEEK = 2 'peek at incoming message
92Const MSG_DONTROUTE = 4 'send without using routing tables
93
94
95'Error code
96Const WSABASEERR = 10000
97Const WSAEINTR = WSABASEERR+4
98Const WSAEBADF = WSABASEERR+9
99Const WSAEACCES = WSABASEERR+13
100Const WSAEFAULT = WSABASEERR+14
101Const WSAEINVAL = WSABASEERR+22
102Const WSAEMFILE = WSABASEERR+24
103Const WSAEWOULDBLOCK = WSABASEERR+35
104Const WSAEINPROGRESS = WSABASEERR+36
105Const WSAEALREADY = WSABASEERR+37
106Const WSAENOTSOCK = WSABASEERR+38
107Const WSAEDESTADDRREQ = WSABASEERR+39
108Const WSAEMSGSIZE = WSABASEERR+40
109Const WSAEPROTOTYPE = WSABASEERR+41
110Const WSAENOPROTOOPT = WSABASEERR+42
111Const WSAEPROTONOSUPPORT = WSABASEERR+43
112Const WSAESOCKTNOSUPPORT = WSABASEERR+44
113Const WSAEOPNOTSUPP = WSABASEERR+45
114Const WSAEPFNOSUPPORT = WSABASEERR+46
115Const WSAEAFNOSUPPORT = WSABASEERR+47
116Const WSAEADDRINUSE = WSABASEERR+48
117Const WSAEADDRNOTAVAIL = WSABASEERR+49
118Const WSAENETDOWN = WSABASEERR+50
119Const WSAENETUNREACH = WSABASEERR+51
120Const WSAENETRESET = WSABASEERR+52
121Const WSAECONNABORTED = WSABASEERR+53
122Const WSAECONNRESET = WSABASEERR+54
123Const WSAENOBUFS = WSABASEERR+55
124Const WSAEISCONN = WSABASEERR+56
125Const WSAENOTCONN = WSABASEERR+57
126Const WSAESHUTDOWN = WSABASEERR+58
127Const WSAETOOMANYREFS = WSABASEERR+59
128Const WSAETIMEDOUT = WSABASEERR+60
129Const WSAECONNREFUSED = WSABASEERR+61
130Const WSAELOOP = WSABASEERR+62
131Const WSAENAMETOOLONG = WSABASEERR+63
132Const WSAEHOSTDOWN = WSABASEERR+64
133Const WSAEHOSTUNREACH = WSABASEERR+65
134Const WSAENOTEMPTY = WSABASEERR+66
135Const WSAEPROCLIM = WSABASEERR+67
136Const WSAEUSERS = WSABASEERR+68
137Const WSAEDQUOT = WSABASEERR+69
138Const WSAESTALE = WSABASEERR+70
139Const WSAEREMOTE = WSABASEERR+71
140Const WSASYSNOTREADY = WSABASEERR+91
141Const WSAVERNOTSUPPORTED = WSABASEERR+92
142Const WSANOTINITIALISED = WSABASEERR+93
143Const WSAEDISCON = WSABASEERR+101
144Const WSAENOMORE = WSABASEERR+102
145Const WSAECANCELLED = WSABASEERR+103
146Const WSAEINVALIDPROCTABLE = WSABASEERR+104
147Const WSAEINVALIDPROVIDER = WSABASEERR+105
148Const WSAEPROVIDERFAILEDINIT =WSABASEERR+106
149Const WSASYSCALLFAILURE = WSABASEERR+107
150Const WSASERVICE_NOT_FOUND = WSABASEERR+108
151Const WSATYPE_NOT_FOUND = WSABASEERR+109
152Const WSA_E_NO_MORE = WSABASEERR+110
153Const WSA_E_CANCELLED = WSABASEERR+111
154Const WSAEREFUSED = WSABASEERR+112
155
156
157
158'---------------
159' WinSock Types
160'---------------
161
162Type HOSTENT
163 h_name As BytePtr
164 h_aliases As DWordPtr
165 h_addrtype As Integer
166 h_length As Integer
167 h_addr_list As DWordPtr
168End Type
169
170Type SERVENT
171 s_name As BytePtr
172 s_aliases As DWordPtr
173 s_port As Integer
174 s_proto As BytePtr
175End Type
176
177Type SOCKADDR
178 sa_family As Word
179 sa_data[13] As Byte
180End Type
181Type SOCKADDR_IN
182 sin_family As Word
183 sin_port As Word
184 sin_addr As DWord
185 sin_zero[7] As Byte
186End Type
187
188
189'-------------
190' WinSock API
191'-------------
192
193Declare Function closesocket Lib "ws2_32.dll" (s As SOCKET) As Long
194Declare Function connect Lib "ws2_32.dll" (s As SOCKET, ByRef name As Any, namelen As Long) As Long
195Declare Function gethostbyname Lib "ws2_32.dll" (name As BytePtr) As *HOSTENT
196Declare Function getservbyname Lib "ws2_32.dll" (name As BytePtr, proto As BytePtr) As *SERVENT
197Declare Function htonl Lib "ws2_32.dll" (hostlong As DWord) As DWord
198Declare Function htons Lib "ws2_32.dll" (hostshort As Word) As Word
199Declare Function recv Lib "ws2_32.dll" (s As SOCKET, buf As BytePtr, length As Long, flags As Long) As Long
200Declare Function send Lib "ws2_32.dll" (s As SOCKET, buf As BytePtr, length As Long, flags As Long) As Long
201
202Const SD_RECEIVE = 0
203Const SD_SEND = 1
204Const SD_BOTH = 2
205Declare Function shutdown Lib "ws2_32.dll" (s As SOCKET, how As Long) As Long
206
207Const SOCK_STREAM = 1
208Const SOCK_DGRAM = 2
209Const SOCK_RAW = 3
210Const SOCK_RDM = 4
211Const SOCK_SEQPACKET = 5
212Declare Function socket Lib "ws2_32.dll" (af As Long, sokettype As Long, protocol As Long) As SOCKET
213
214Declare Function WSACleanup Lib "ws2_32.dll" () As Integer
215
216Const WSADESCRIPTION_LEN = 256
217Const WSASYS_STATUS_LEN = 128
218Type WSADATA
219 wVersion As Word
220 wHighVersion As Word
221 szDescription[WSADESCRIPTION_LEN] As Byte
222 szSystemStatus[WSASYS_STATUS_LEN] As Byte
223 iMaxSockets As Word
224 iMaxUdpDg As Word
225 lpVendorInfo As BytePtr
226End Type
227Declare Function WSAStartup Lib "ws2_32.dll" (wVersionRequested As Word, ByRef lpWSAData As WSADATA) As Long
228
229
230Declare Function accept Lib "ws2_32.dll" (s As SOCKET, ByRef addr As SOCKADDR_IN, ByVal addrlen As Long) As SOCKET
231Declare Function bind Lib "ws2_32.dll" (s As SOCKET, ByRef sName As SOCKADDR_IN, ByVal namelen As Long) As Long
232Declare Function ioctlsocket Lib "ws2_32.dll" (s As SOCKET, ByVal cmd As Long, argp As DWord) As Long
233Declare Function listen Lib "ws2_32.dll" (s As SOCKET, ByVal backlog As Long) As Long
234
235Declare 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
236Declare 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
237
238Const INADDR_ANY = &h0
239
240Declare Function htons Lib "ws2_32.dll" (netshort As Word) As Word
241Declare Function htonl Lib "ws2_32.dll" (netshort As DWord) As DWord
242Declare Function ntohs Lib "ws2_32.dll" (netshort As Word) As Word
243Declare Function ntohl Lib "ws2_32.dll" (netshort As DWord) As DWord
244
245#endif '_INC_WINSOCK2
Note: See TracBrowser for help on using the repository browser.