Example #1
0
int SocketTracker::init()
{
	OutputDebugString("Socket Tracker Init\n");

	// add init code
    m_dwThreadID = 0;
    m_hThread    = 0;

	ListenSocket = INVALID_SOCKET;
	ClientSocket = INVALID_SOCKET;

	WSADATA wsaData;
	int result = WSAStartup(MAKEWORD(2, 2), &wsaData);		// starts Winsock version 2.2 and initializes wsaData

	if(result != 0)											// Winsock failed to launch
		return false;
	
	if(wsaData.wVersion != MAKEWORD(2, 2))					// winsock is not version 2.2
	{
		WSACleanup();
		return false;
	}

	// change to support other ports
	return ListenOnPort(DEFAULT_PORT);
}
int XLSocket::Start()
{
	m_Config.Print();
	int ErrorCode = RESULT_OK;
	if(m_bServerMode)
	{
		if((ErrorCode = ListenOnPort()) != RESULT_OK)
		{
			return ErrorCode;
		}
		if(!AcceptConnection())
		{
			return RESULT_FAIL;
		}
		m_bActive = true;
	}
	else
	{
		if((ErrorCode = TryConnect()) != RESULT_OK)
		{
			return ErrorCode;
		}
		m_bActive = true;
	}
	return ErrorCode;
}
Example #3
0
int main(int ac, char* av)
{
	ListenOnPort(10000);
	CloseConnection();
	return 0;
}