Example #1
0
int main(void)
{
	if( !initSockets(true) )
		return 1;

	IConnection * tcpConnection = new TCPConnection();

	if(static_cast<TCPConnection*>(tcpConnection)->connect(Socket::localIP(), 1024))
		std::cout << "Connected!" << std::endl;
	else
		std::cout << "Error connecting! #" << WSAGetLastError() << std::endl;

	if( 14 != tcpConnection->send((ubyte*)"hello, world!", 14) )
		std::cout << "send failed!" << std::endl;

	std::cout << std::endl << tcpConnection->connectionInfo() << std::endl;

	// wait for input.
	std::getchar();

	static_cast<TCPConnection*>(tcpConnection)->close();

	// cleanup.
	cleanSockets();
	return 0;
}
Example #2
0
int WINAPI WinMain(HINSTANCE instanceH, HINSTANCE prevInstanceH, LPSTR command_line, int show)
{
	gWIN_WIDTH = 800;
	gWIN_HEIGHT = 600;
	// Initialize the system
	AESysInit (instanceH, show);

	GameStateManager gsm;
	
	gsm.init(new GameState_StartServer());

	initSockets(true);

	while(!gsm.quit())
	{
		// reset the system modules
		AESysReset();

		// If not restarting, load the gamestate
		if(!gsm.restart())
			gsm.loadState();
		else
			gsm.restartState();

		// Initialize the gamestate
		gsm.initState();

		while(!gsm.changeState())
		{
			AESysFrameStart();

			AEInputUpdate();

			gsm.updateState();
			gsm.drawState();
			
			AESysFrameEnd();

			// check if forcing the application to quit
			gsm.quit((gAESysWinExists == false) || AEInputCheckTriggered(DIK_ESCAPE));
		}
		
		gsm.freeState();

		if(!gsm.restart())
			gsm.unloadState();

		gsm.nextState();
	}

	cleanSockets();

	// free the system
	AESysExit();
}