www.gusucode.com > VC++三子棋游戏源码(类似五子棋)-源码程序 > VC++三子棋游戏源码(类似五子棋)-源码程序\code\Server\main.cpp

    //Download by http://www.NewXing.com
//main.cpp
//////
#include "stdafx.h"
#include "Global.h"
/////
/////
/////
int main()
{
	//////////
	{
		time_t ltime;
		struct tm *today = NULL;
		time(&ltime);
		today = localtime(&ltime);
		printf("Enter: %02d:%02d:%02d\n\n",today->tm_hour,today->tm_min,today->tm_sec);
	}
	printf("Press <Esc> to EXIT...\n\n");
	//////////

	//////////
	printf("Waiting for starting server...\n\n");
	g_tTcpIpConnection.StartServer();
	/////////

	while(getch() != 27) Sleep(50);//ESC

	
	//Stop all threads
	printf("Waiting for stoping server...\n\n");
	g_tTcpIpConnection.m_bListening = FALSE;
	char *szServerName = "127.0.0.1";
	int nPort = PORTID;
	g_tTcpIpConnection.ConnectToServer(szServerName, nPort, INVALID_ID_B);
	Sleep(500);
	g_tTcpIpConnection.StopServer();
	////

	//////////
	{
		time_t ltime;
		struct tm *today = NULL;
		time(&ltime);
		today = localtime(&ltime);
		printf("\n\nLeave: %02d:%02d:%02d\n\n",today->tm_hour,today->tm_min,today->tm_sec);
	}
	//////////
	
	return 0;
}