Commit 04734eae authored by Cyril Deguet's avatar Cyril Deguet

- Winsock works now !

parent bf38b557
......@@ -2,7 +2,7 @@
* socket.cpp: socket management
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: socket.cpp,v 1.8 2002/03/26 17:01:36 bozo Exp $
* $Id: socket.cpp,v 1.9 2002/04/25 14:57:28 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -452,6 +452,9 @@ void C_Socket::Bind(const C_String& strIntf, const C_String& strPort)
int iRc = bind(m_hSocket, pAddr, iAddrLen);
if(iRc)
{
#ifdef _WIN32
iRc = WSAGetLastError();
#endif
throw E_Socket("Unable to bind to " + strIntf + " on port " + strPort +
": " + GetErrorMsg(SYSTEM_NETWORK));
}
......
......@@ -2,7 +2,7 @@
* system.cpp: System base functions
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: system.cpp,v 1.1 2001/10/06 21:23:36 bozo Exp $
* $Id: system.cpp,v 1.2 2002/04/25 14:57:28 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -59,11 +59,7 @@
//------------------------------------------------------------------------------
int GetErrorCode(int iSubSystem/* = SYSTEM_DEFAULT*/)
{
#ifdef HAVE_STRERROR
ASSERT(iSubSystem != SYSTEM_LIBRARY);
return errno;
#elif defined WIN32
#if _WIN32
switch(iSubSystem)
{
case SYSTEM_DEFAULT:
......@@ -73,7 +69,10 @@ int GetErrorCode(int iSubSystem/* = SYSTEM_DEFAULT*/)
default:
ASSERT(false);
return GEN_ERR;
}
}
#elif defined HAVE_STRERROR
ASSERT(iSubSystem != SYSTEM_LIBRARY);
return errno;
#endif
}
......@@ -88,10 +87,7 @@ int GetErrorCode(int iSubSystem/* = SYSTEM_DEFAULT*/)
//------------------------------------------------------------------------------
C_String GetErrorMsg(int iSubSystem/* = SYSTEM_DEFAULT*/)
{
#ifdef HAVE_STRERROR
return C_String(strerror(GetErrorCode(iSubSystem)));
#elif defined WIN32
#ifdef _WIN32
// Get the system error code
DWORD dwErrorCode = GetErrorCode(iSubSystem);
......@@ -115,7 +111,8 @@ C_String GetErrorMsg(int iSubSystem/* = SYSTEM_DEFAULT*/)
// To do: trim the string (\n, \r and .)
LocalFree(lpBuff);
return strMessage;
#elif defined HAVE_STRERROR
return C_String(strerror(GetErrorCode(iSubSystem)));
#endif
}
......
......@@ -2,7 +2,7 @@
* thread.cpp: thread management
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: thread.cpp,v 1.4 2002/03/25 00:42:21 asmax Exp $
* $Id: thread.cpp,v 1.5 2002/04/25 14:57:28 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -273,9 +273,9 @@ void C_Thread::Create()
pthread_attr_destroy(&sAttr);
#elif defined _WIN32
unsigned threadID;
hThread = (HANDLE)_beginthreadex(NULL, 0,
(PTHREAD_START) C_Thread::StartRoutine, this, 0, &threadID);
unsigned long threadID;
hThread = (HANDLE)CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE)C_Thread::StartRoutine, this, 0, &threadID);
int iRc = ( hThread ? 0 : 1 );
#endif
......
......@@ -2,7 +2,7 @@
* vls.cpp: vls main file
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: vls.cpp,v 1.5 2001/11/29 17:55:19 bozo Exp $
* $Id: vls.cpp,v 1.6 2002/04/25 14:57:29 asmax Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -31,9 +31,10 @@
#include "../core/defs.h"
#ifdef GETPROTOBYNAME_IN_NETDB_H
#include <netdb.h>
#elif defined WIN32
#include <winsock2.h>
#include <netdb.h>
#endif
#ifdef _WIN32
#include <winsock2.h>
#endif
#include "config.h"
......@@ -86,9 +87,21 @@ int C_Vls::OnAppInit()
{
// Startup message
printf("%s\n", PGRM_INFO);
// Check environnement
int iRc = CheckEnvir();
int iRc = CheckEnvir();
#ifdef _WIN32
// Initialize Winsock
WSADATA data;
int version = (u16)((u8)1 | (u16((u8)(1))) << 8);
iRc = WSAStartup(version, &data);
if (iRc)
{
printf("Unable to load Winsock 1.1\n");
}
#endif
if(!iRc)
{
......@@ -143,6 +156,10 @@ int C_Vls::OnAppExit()
m_pAdministrator->DisableRequests();
iRc = m_pAdministrator->Stop();
}
#ifdef _WIN32
WSACleanup();
#endif
return iRc;
}
......
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