1 | #ifndef D_WINSOCK_H
|
---|
2 | #define D_WINSOCK_H
|
---|
3 |
|
---|
4 |
|
---|
5 | /* get most definitions from the real winsock */
|
---|
6 | #include <winsock.h>
|
---|
7 |
|
---|
8 |
|
---|
9 | #define D_NOERROR 0
|
---|
10 | #define D_ERR_UNEXPECTED 1
|
---|
11 | #define D_ERR_LOADFAILED 2
|
---|
12 | #define D_ERR_FREELIBFAILED 3
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 | // d_LoadWinsock must be called before an normal winsock
|
---|
17 | // functions
|
---|
18 |
|
---|
19 |
|
---|
20 | // expects path to be NULL, a empty string, or a path which ends in a slash
|
---|
21 | // returns D_NOERROR on success,
|
---|
22 | // D_ERR_UNEXPECTED or D_ERR_LOADFAILED on failure
|
---|
23 | int d_LoadWinsock (char *path);
|
---|
24 |
|
---|
25 | // returns D_NOERROR on success,
|
---|
26 | // D_ERR_FREELIBFAILED on failure
|
---|
27 | int d_UnloadWinsock ();
|
---|
28 |
|
---|
29 |
|
---|
30 | // dynamically loaded versions of the winsock functions
|
---|
31 |
|
---|
32 | SOCKET d_accept (SOCKET s, struct sockaddr *addr, int *addrlen);
|
---|
33 | int d_bind (SOCKET s, const struct sockaddr *addr, int namelen);
|
---|
34 | int d_closesocket (SOCKET s);
|
---|
35 | int d_connect (SOCKET s, const struct sockaddr *name, int namelen);
|
---|
36 | int d_ioctlsocket (SOCKET s, long cmd, u_long *argp);
|
---|
37 | int d_getpeername (SOCKET s, struct sockaddr *name, int *namelen);
|
---|
38 | int d_getsockname (SOCKET s, struct sockaddr *name, int *namelen);
|
---|
39 | int d_getsockopt (SOCKET s, int level, int optname, char *optval, int *optlen);
|
---|
40 | u_long d_htonl (u_long hostlong);
|
---|
41 | u_short d_htons (u_short hostshort);
|
---|
42 | unsigned long d_inet_addr (const char *cp);
|
---|
43 | char *d_inet_ntoa (struct in_addr in);
|
---|
44 | int d_listen (SOCKET s, int backlog);
|
---|
45 | u_long d_ntohl (u_long netlong);
|
---|
46 | u_short d_ntohs (u_short netshort);
|
---|
47 | int d_recv (SOCKET s, char *buf, int len, int flags);
|
---|
48 | int d_recvfrom (SOCKET s, char *buf, int len, int flags,
|
---|
49 | struct sockaddr *from, int *fromlen);
|
---|
50 | int d_select (int nfds, fd_set *readfds, fd_set *writefds,
|
---|
51 | fd_set *exceptfds, const struct timeval *timeout);
|
---|
52 | int d_send (SOCKET s, const char *buf, int len, int flags);
|
---|
53 | int d_sendto (SOCKET s, const char *buf, int len, int flags,
|
---|
54 | const struct sockaddr *to, int tolen);
|
---|
55 | int d_setsockopt (SOCKET s, int level, int optname,
|
---|
56 | const char *optval, int optlen);
|
---|
57 | int d_shutdown (SOCKET s, int how);
|
---|
58 | SOCKET d_socket (int af, int type, int protocol);
|
---|
59 |
|
---|
60 | hostent *d_gethostbyaddr(const char *addr, int len, int type);
|
---|
61 | hostent *d_gethostbyname(const char *name);
|
---|
62 | int d_gethostname (char *name, int namelen);
|
---|
63 | servent *d_getservbyport(int port, const char *proto);
|
---|
64 | servent *d_getservbyname(const char *name, const char *proto);
|
---|
65 | protoent *d_getprotobynumber(int proto);
|
---|
66 | protoent *d_getprotobyname(const char *name);
|
---|
67 |
|
---|
68 | int d_WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
|
---|
69 | int d_WSACleanup(void);
|
---|
70 | void d_WSASetLastError(int iError);
|
---|
71 | int d_WSAGetLastError(void);
|
---|
72 | BOOL d_WSAIsBlocking(void);
|
---|
73 | int d_WSAUnhookBlockingHook(void);
|
---|
74 | FARPROC d_WSASetBlockingHook(FARPROC lpBlockFunc);
|
---|
75 | int d_WSACancelBlockingCall(void);
|
---|
76 | HANDLE d_WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
|
---|
77 | const char *name,
|
---|
78 | const char *proto,
|
---|
79 | char *buf, int buflen);
|
---|
80 | HANDLE d_WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port,
|
---|
81 | const char *proto, char *buf,
|
---|
82 | int buflen);
|
---|
83 | HANDLE d_WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
|
---|
84 | const char *name, char *buf,
|
---|
85 | int buflen);
|
---|
86 | HANDLE d_WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
|
---|
87 | int number, char *buf,
|
---|
88 | int buflen);
|
---|
89 | HANDLE d_WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
|
---|
90 | const char *name, char *buf,
|
---|
91 | int buflen);
|
---|
92 | HANDLE d_WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg,
|
---|
93 | const char *addr, int len, int type,
|
---|
94 | char *buf, int buflen);
|
---|
95 | int d_WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
|
---|
96 | int d_WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg,
|
---|
97 | long lEvent);
|
---|
98 |
|
---|
99 |
|
---|
100 |
|
---|
101 |
|
---|
102 |
|
---|
103 | #endif
|
---|