?? socketfun.cpp
字號(hào):
// SocketFun.cpp: implementation of the CSocketFun class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "try4.h"
#include "SocketFun.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSocketFun::CSocketFun()
{
}
CSocketFun::~CSocketFun()
{
}
int CSocketFun::StartUp()
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 0 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
// Couldn't find a usable WinSock DLL. */
return err;
}
// Confirm that the WinSock DLL supports 2.0.
// Note that if the DLL supports versions greater
// than 2.0 in addition to 2.0, it will still return
// 2.0 in wVersion since that is the version we
// requested.
if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 0 ) {
// Couldn't find a usable WinSock DLL.
WSACleanup( );
return WSAVERNOTSUPPORTED;
}
// The WinSock DLL is acceptable
return 0;
}
int CSocketFun::CleanUp()
{
int nRetCode;
nRetCode = WSACleanup();
if (nRetCode != 0) {
// An error occured.
return WSAGetLastError();
}
return 0;
}