path: root/compat/mingw.h
diff options
authorJohannes Sixt <>2007-12-26 12:51:18 (GMT)
committerJohannes Sixt <>2008-06-26 06:45:09 (GMT)
commit746fb8574459798d127e3f9cf782ccb8e31c9e45 (patch)
treee1c59cd794cedc573f4a2ee81ae9291277d9bdce /compat/mingw.h
parent87bddba9924045e39e988d9704714db90abd5619 (diff)
Windows: Implement wrappers for gethostbyname(), socket(), and connect().
gethostbyname() is the first function that calls into the Winsock library, and it is wrapped only to initialize the library. socket() is wrapped for two reasons: - Windows's socket() creates things that are like low-level file handles, and they must be converted into file descriptors first. - And these handles cannot be used with plain ReadFile()/WriteFile() because they are opened for "overlapped IO". We have to use WSASocket() to create non-overlapped IO sockets. connect() must be wrapped because Windows's connect() expects the low-level sockets, not file descriptors, and we must first unwrap the file descriptor before we can pass it on to Windows's connect(). Signed-off-by: Johannes Sixt <>
Diffstat (limited to 'compat/mingw.h')
1 files changed, 9 insertions, 0 deletions
diff --git a/compat/mingw.h b/compat/mingw.h
index 0879894..1017632 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -148,6 +148,15 @@ int mingw_open (const char *filename, int oflags, ...);
char *mingw_getcwd(char *pointer, int len);
#define getcwd mingw_getcwd
+struct hostent *mingw_gethostbyname(const char *host);
+#define gethostbyname mingw_gethostbyname
+int mingw_socket(int domain, int type, int protocol);
+#define socket mingw_socket
+int mingw_connect(int sockfd, struct sockaddr *sa, size_t sz);
+#define connect mingw_connect
int mingw_rename(const char*, const char*);
#define rename mingw_rename