summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-09-20 16:30:07 +0000
committerjstebbins <[email protected]>2009-09-20 16:30:07 +0000
commitd94b403a57815095142e1c495fccc938df5e11e7 (patch)
tree9b2eb0fdd3f90e86d8feed6712ce6d092f6996b9 /libhb
parentb555439da6188954063c9bed6f4c22dd90ca438b (diff)
libhb: fix gethostbyname failure on mingw
winsock requires initialization before you can call any networking functions git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2830 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/ports.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libhb/ports.c b/libhb/ports.c
index 6368bcba4..120038618 100644
--- a/libhb/ports.c
+++ b/libhb/ports.c
@@ -644,6 +644,23 @@ hb_net_t * hb_net_open( char * address, int port )
struct sockaddr_in sock;
struct hostent * host;
+#ifdef SYS_MINGW
+ WSADATA wsaData;
+ int iResult, winsock_init = 0;
+
+ // Initialize Winsock
+ if (!winsock_init)
+ {
+ iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
+ if (iResult != 0)
+ {
+ hb_log("WSAStartup failed: %d", iResult);
+ return NULL;
+ }
+ winsock_init = 1;
+ }
+#endif
+
/* TODO: find out why this doesn't work on Win32 */
if( !( host = gethostbyname( address ) ) )
{