?? printserver.cpp
字號:
// PrintServer.cpp : Defines the entry point for the console application.
//
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include "TCPListen.h"
#include "OS.h"
void catch_c(int sig)
{
printf("Catch succeed!\n");
exit(1);
}
#ifdef _WIN32
int InitSocket()
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 )
{
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
return 0;
}
/* Confirm that the WinSock DLL supports 2.2.*/
/* Note that if the DLL supports versions greater */
/* than 2.2 in addition to 2.2, it will still return */
/* 2.2 in wVersion since that is the version we */
/* requested. */
if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
WSACleanup( );
return 0;
}
return 1; /* The WinSock DLL is acceptable. Proceed. */
}
#endif
int main(int argc, char* argv[])
{
CTCPListen tcpListen;
char chLog[100],chTime[21];
#ifdef _WIN32
if(InitSocket()!=1)
{
printf("Init socket failed!");
return 0;
}
#endif
OS::GetSysDate(chTime,1);
signal(SIGINT,catch_c);
CSHPPSession::Initialize();
#ifndef _WIN32
sprintf(chLog,"/home/oracle/server/p_%s.log",chTime);
#else
sprintf(chLog,"p_%s.log",chTime);
#endif //_WIN32
OSThread::TOpen(chLog);
printf("Log file name:");
printf(chLog);
printf("\n");
OS::GetSysDateTime(chTime);
tcpListen.Start();
sprintf(chLog,"%s服務器開始啟動!\r\n",chTime);
OSThread::TWrite(chLog,strlen(chLog));
printf(chLog);
tcpListen.Join();
tcpListen.Close();
OS::GetSysDateTime(chTime);
sprintf(chLog,"%服務器關閉\r\n",chTime);
OSThread::TWrite(chLog,strlen(chLog));
OSThread::TClose();
printf(chLog);
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -