Commit cdf12612 authored by Sam Hocevar's avatar Sam Hocevar

  * Fixed the vlcs communication issue by initializing WinSock at
    startup (thanks Meuuh for the tip).
parent 6389eac3
...@@ -133,6 +133,7 @@ C_OBJ += src/misc/darwin_specific.o ...@@ -133,6 +133,7 @@ C_OBJ += src/misc/darwin_specific.o
endif endif
ifneq (,$(findstring mingw32,$(SYS))) ifneq (,$(findstring mingw32,$(SYS)))
C_OBJ += src/misc/win32_specific.o
RESOURCE_OBJ := share/vlc_win32_rc.o RESOURCE_OBJ := share/vlc_win32_rc.o
endif endif
......
/*****************************************************************************
* win32_specific.h: Win32 specific features
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: win32_specific.h,v 1.1 2001/11/12 22:42:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Prototypes
*****************************************************************************/
void system_Init ( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] );
void system_End ( void );
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input.c,v 1.153 2001/11/12 04:12:37 sam Exp $ * $Id: input.c,v 1.154 2001/11/12 22:42:56 sam Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -52,7 +52,9 @@ ...@@ -52,7 +52,9 @@
# include <netdb.h> /* hostent ... */ # include <netdb.h> /* hostent ... */
# include <sys/socket.h> # include <sys/socket.h>
# include <netinet/in.h> # include <netinet/in.h>
# include <arpa/inet.h> # ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> /* inet_ntoa(), inet_aton() */
# endif
#endif #endif
#ifdef HAVE_SYS_TIMES_H #ifdef HAVE_SYS_TIMES_H
...@@ -728,22 +730,6 @@ static void NetworkOpen( input_thread_t * p_input ) ...@@ -728,22 +730,6 @@ static void NetworkOpen( input_thread_t * p_input )
struct sockaddr_in sock; struct sockaddr_in sock;
unsigned int i_mc_group; unsigned int i_mc_group;
#ifdef WIN32
WSADATA Data;
int i_err;
#endif
#ifdef WIN32
/* WinSock Library Init. */
i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
if( i_err )
{
intf_ErrMsg( "input: can't initiate WinSocks, error %i", i_err );
return ;
}
#endif
/* Get the remote server */ /* Get the remote server */
if( p_input->p_source != NULL ) if( p_input->p_source != NULL )
{ {
...@@ -993,10 +979,6 @@ static void NetworkClose( input_thread_t * p_input ) ...@@ -993,10 +979,6 @@ static void NetworkClose( input_thread_t * p_input )
intf_WarnMsg( 2, "input: closing network target `%s'", p_input->p_source ); intf_WarnMsg( 2, "input: closing network target `%s'", p_input->p_source );
close( p_input->i_handle ); close( p_input->i_handle );
#ifdef WIN32
WSACleanup();
#endif
} }
/***************************************************************************** /*****************************************************************************
...@@ -1012,22 +994,6 @@ static void HTTPOpen( input_thread_t * p_input ) ...@@ -1012,22 +994,6 @@ static void HTTPOpen( input_thread_t * p_input )
struct sockaddr_in sock; struct sockaddr_in sock;
char psz_buffer[256]; char psz_buffer[256];
#ifdef WIN32
WSADATA Data;
int i_err;
#endif
#ifdef WIN32
/* WinSock Library Init. */
i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
if( i_err )
{
intf_ErrMsg( "input: can't initiate WinSocks, error %i", i_err );
return ;
}
#endif
/* Get the remote server */ /* Get the remote server */
if( p_input->p_source != NULL ) if( p_input->p_source != NULL )
{ {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* and spawn threads. * and spawn threads.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: main.c,v 1.123 2001/11/12 20:16:33 sam Exp $ * $Id: main.c,v 1.124 2001/11/12 22:42:56 sam Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -92,6 +92,10 @@ ...@@ -92,6 +92,10 @@
# include "darwin_specific.h" # include "darwin_specific.h"
#endif #endif
#ifdef WIN32
# include "win32_specific.h"
#endif
#include "netutils.h" /* network_ChannelJoin */ #include "netutils.h" /* network_ChannelJoin */
#include "main.h" #include "main.h"
...@@ -288,7 +292,7 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] ) ...@@ -288,7 +292,7 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
/* /*
* System specific initialization code * System specific initialization code
*/ */
#if defined( SYS_BEOS ) || defined( SYS_DARWIN ) #if defined( SYS_BEOS ) || defined( SYS_DARWIN ) || defined( WIN32 )
system_Init( &i_argc, ppsz_argv, ppsz_env ); system_Init( &i_argc, ppsz_argv, ppsz_env );
#elif defined( WIN32 ) #elif defined( WIN32 )
...@@ -440,7 +444,7 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] ) ...@@ -440,7 +444,7 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
/* /*
* System specific cleaning code * System specific cleaning code
*/ */
#if defined( SYS_BEOS ) || defined( SYS_DARWIN ) #if defined( SYS_BEOS ) || defined( SYS_DARWIN ) || defined( WIN32 )
system_End(); system_End();
#endif #endif
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* netutils.c: various network functions * netutils.c: various network functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: netutils.c,v 1.42 2001/11/12 20:16:33 sam Exp $ * $Id: netutils.c,v 1.43 2001/11/12 22:42:56 sam Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Benoit Steiner <benny@via.ecp.fr> * Benoit Steiner <benny@via.ecp.fr>
...@@ -38,23 +38,24 @@ ...@@ -38,23 +38,24 @@
#endif #endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> /* gethostname() */ # include <unistd.h> /* gethostname() */
#elif defined( _MSC_VER ) && defined( _WIN32 ) #elif defined( _MSC_VER ) && defined( _WIN32 )
#include <io.h> # include <io.h>
#endif #endif
#if !defined( _MSC_VER ) #if !defined( _MSC_VER )
#include <sys/time.h> /* gettimeofday */ #include <sys/time.h> /* gettimeofday */
#endif #endif
#if !defined( WIN32 ) #ifdef WIN32
#include <netdb.h> /* gethostbyname() */ # include <winsock2.h>
#include <netinet/in.h> /* BSD: struct in_addr */ #elif !defined( SYS_BEOS ) && !defined( SYS_NTO )
#include <sys/socket.h> /* BSD: struct sockaddr */ # include <netdb.h> /* hostent ... */
#endif # include <sys/socket.h> /* BSD: struct sockaddr */
# include <netinet/in.h> /* BSD: struct in_addr */
#ifdef HAVE_ARPA_INET_H # ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h> /* inet_ntoa(), inet_aton() */ # include <arpa/inet.h> /* inet_ntoa(), inet_aton() */
# endif
#endif #endif
#ifdef SYS_LINUX #ifdef SYS_LINUX
...@@ -287,6 +288,12 @@ int network_ChannelJoin( int i_channel ) ...@@ -287,6 +288,12 @@ int network_ChannelJoin( int i_channel )
/* Initializing the socket */ /* Initializing the socket */
i_fd = socket( AF_INET, SOCK_DGRAM, 0 ); i_fd = socket( AF_INET, SOCK_DGRAM, 0 );
if( i_fd < 0 )
{
intf_ErrMsg( "network error: unable to create vlcs socket (%s)",
strerror( errno ) );
return -1;
}
/* Getting information about the channel server */ /* Getting information about the channel server */
psz_vlcs = main_GetPszVariable( INPUT_CHANNEL_SERVER_VAR, psz_vlcs = main_GetPszVariable( INPUT_CHANNEL_SERVER_VAR,
...@@ -294,7 +301,8 @@ int network_ChannelJoin( int i_channel ) ...@@ -294,7 +301,8 @@ int network_ChannelJoin( int i_channel )
i_port = main_GetIntVariable( INPUT_CHANNEL_PORT_VAR, i_port = main_GetIntVariable( INPUT_CHANNEL_PORT_VAR,
INPUT_CHANNEL_PORT_DEFAULT ); INPUT_CHANNEL_PORT_DEFAULT );
intf_WarnMsg( 6, "network: vlcs '%s', port %d", psz_vlcs, i_port ); intf_WarnMsg( 5, "network: socket %i, vlcs '%s', port %d",
i_fd, psz_vlcs, i_port );
memset( &sa_client, 0x00, sizeof(struct sockaddr_in) ); memset( &sa_client, 0x00, sizeof(struct sockaddr_in) );
memset( &sa_server, 0x00, sizeof(struct sockaddr_in) ); memset( &sa_server, 0x00, sizeof(struct sockaddr_in) );
...@@ -310,11 +318,11 @@ int network_ChannelJoin( int i_channel ) ...@@ -310,11 +318,11 @@ int network_ChannelJoin( int i_channel )
#endif #endif
/* Bind the socket */ /* Bind the socket */
i_dummy = bind( i_fd, (struct sockaddr *)(&sa_client), if( bind( i_fd, (struct sockaddr*)(&sa_client), sizeof(sa_client) ) )
sizeof(struct sockaddr) );
if ( i_dummy )
{ {
intf_ErrMsg( "network: unable to bind vlcs socket: %i", i_dummy ); intf_ErrMsg( "network: unable to bind vlcs socket (%s)",
strerror( errno ) );
close( i_fd );
return -1; return -1;
} }
...@@ -322,6 +330,7 @@ int network_ChannelJoin( int i_channel ) ...@@ -322,6 +330,7 @@ int network_ChannelJoin( int i_channel )
if( GetMacAddress( i_fd, psz_mac ) ) if( GetMacAddress( i_fd, psz_mac ) )
{ {
intf_ErrMsg( "network error: failed getting MAC address" ); intf_ErrMsg( "network error: failed getting MAC address" );
close( i_fd );
return -1; return -1;
} }
...@@ -347,9 +356,8 @@ int network_ChannelJoin( int i_channel ) ...@@ -347,9 +356,8 @@ int network_ChannelJoin( int i_channel )
delay.tv_usec = 0; delay.tv_usec = 0;
FD_ZERO( &fds ); FD_ZERO( &fds );
FD_SET( i_fd, &fds ); FD_SET( i_fd, &fds );
i_dummy = select( i_fd + 1, &fds, NULL, NULL, &delay );
switch( i_dummy ) switch( select( i_fd + 1, &fds, NULL, NULL, &delay ) )
{ {
case 0: case 0:
intf_ErrMsg( "network error: no answer from vlcs" ); intf_ErrMsg( "network error: no answer from vlcs" );
...@@ -396,7 +404,7 @@ int network_ChannelJoin( int i_channel ) ...@@ -396,7 +404,7 @@ int network_ChannelJoin( int i_channel )
#else #else
intf_ErrMsg( "network error: channels not supported on this platform" ); intf_ErrMsg( "network error: channels not supported on this platform" );
return NULL; return -1;
#endif #endif
} }
......
/*****************************************************************************
* win32_specific.c: Win32 specific features
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: win32_specific.c,v 1.1 2001/11/12 22:42:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include "defs.h"
#include <string.h> /* strdup() */
#include <stdlib.h> /* free() */
#include <winsock2.h>
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "win32_specific.h"
/*****************************************************************************
* system_Init: initialize winsock.
*****************************************************************************/
void system_Init( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] )
{
WSADATA Data;
int i_err;
/* WinSock Library Init. */
i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
if( i_err )
{
fprintf( stderr, "error: can't initiate WinSocks, error %i", i_err );
}
}
/*****************************************************************************
* system_End: terminate winsock.
*****************************************************************************/
void system_End( void )
{
WSACleanup();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment