From 7483649514ed2049deaf59077dbb77c915ba22a0 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Wed, 15 Sep 2010 18:25:18 +1000 Subject: win32: reimplement connect() connect() now returns a socket handle, i.e. a HANDLE. This kind of handle works with read()/write(). But on the other hand, FILE* functions are dead because they are not crt file handles?? --- include/mingw.h | 2 ++ win32/net.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/mingw.h b/include/mingw.h index b2d73ce1b..1caf65464 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -176,8 +176,10 @@ NOIMPL(ioctl,int fd UNUSED_PARAM, int code UNUSED_PARAM,...); #ifdef CONFIG_WIN32_NET int mingw_socket(int domain, int type, int protocol); +int mingw_connect(int sockfd, struct sockaddr *sa, size_t sz); # define socket mingw_socket +# define connect mingw_connect #endif NOIMPL(mingw_sendto,SOCKET s UNUSED_PARAM, const char *buf UNUSED_PARAM, int len UNUSED_PARAM, int flags UNUSED_PARAM, const struct sockaddr *sa UNUSED_PARAM, int salen UNUSED_PARAM); NOIMPL(mingw_listen,SOCKET s UNUSED_PARAM,int backlog UNUSED_PARAM); diff --git a/win32/net.c b/win32/net.c index 98204b99c..eadda6b69 100644 --- a/win32/net.c +++ b/win32/net.c @@ -45,3 +45,10 @@ int mingw_socket(int domain, int type, int protocol) } return sockfd; } + +#undef connect +int mingw_connect(int sockfd, struct sockaddr *sa, size_t sz) +{ + SOCKET s = (SOCKET)_get_osfhandle(sockfd); + return connect(s, sa, sz); +} -- cgit v1.2.3-55-g6feb