From 307532819d6117d154436da4131ca645f7691a63 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Wed, 8 Dec 2010 17:19:12 +0200 Subject: [PATCH] =?utf8?q?=D0=92=20=D0=BA=D0=BE=D0=BD=D1=81=D0=BE=D0=BB?= =?utf8?q?=D1=8C=D0=BD=D0=BE=D0=BC=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8?= =?utf8?q?=D0=B7=D0=B0=D1=82=D0=BE=D1=80=D0=B5=20=D0=B2=20=D0=BA=D0=BB?= =?utf8?q?=D0=B0=D1=81=D1=81=D0=B5=20=D0=BE=D1=82=D0=B2=D0=B5=D1=87=D0=B0?= =?utf8?q?=D1=8E=D1=89=D0=B5=D0=BC=20=D0=B7=D0=B0=20WEB-=D0=B8=D0=BD=D1=82?= =?utf8?q?=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=20=D0=BF=D1=80=D0=BE=D0=B2?= =?utf8?q?=D0=B5=D0=B4=D0=B5=D0=BD=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?utf8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BA=D0=BE=D0=B4=D0=B0,=20?= =?utf8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=B8?= =?utf8?q?=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86?= =?utf8?q?=D0=B8=D1=8F=20=D0=BD=D0=B5=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=8B?= =?utf8?q?=D1=85=20=D1=87=D0=BB=D0=B5=D0=BD=D0=BE=D0=B2,=20=D1=83=D0=BC?= =?utf8?q?=D0=B5=D0=BD=D1=8C=D1=88=D0=B5=D0=BD=D0=B0=20=D0=BE=D0=B1=D0=BB?= =?utf8?q?=D0=B0=D1=81=D1=82=D1=8C=20=D0=B2=D0=B8=D0=B4=D0=B8=D0=BC=D0=BE?= =?utf8?q?=D1=81=D1=82=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD?= =?utf8?q?=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- projects/sgauth/web.cpp | 15 +++++++++++---- projects/sgauth/web.h | 31 ++++++++++--------------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/projects/sgauth/web.cpp b/projects/sgauth/web.cpp index caec33a0..ffab862b 100644 --- a/projects/sgauth/web.cpp +++ b/projects/sgauth/web.cpp @@ -56,8 +56,7 @@ WEB::WEB() listenSocket(0), outerSocket(0), refreshPeriod(0), - listenWebAddr(0), - outerAddrLen(0) + listenWebAddr(0) { #ifdef WIN32 res = WSAStartup(MAKEWORD(2,0), &wsaData); @@ -89,6 +88,8 @@ pthread_create(&thread, NULL, RunWeb, NULL); void WEB::PrepareNet() { listenSocket = socket(PF_INET, SOCK_STREAM, 0); + +struct sockaddr_in listenAddr; listenAddr.sin_family = AF_INET; listenAddr.sin_port = htons(LISTEN_PORT); listenAddr.sin_addr.s_addr = listenWebAddr; @@ -120,8 +121,6 @@ if (res == -1) printf("Listen failed.\n"); exit(0); } - -outerAddrLen = sizeof(outerAddr); } //--------------------------------------------------------------------------- void WEB::SetRefreshPagePeriod(int p) @@ -142,6 +141,14 @@ PrepareNet(); char recvBuffer[4096]; while (1) { + struct sockaddr_in outerAddr; + + #ifndef WIN32 + socklen_t outerAddrLen = sizeof(outerAddr); + #else + int outerAddrLen = sizeof(outerAddr); + #endif + outerSocket = accept(listenSocket, (struct sockaddr*)&outerAddr, &outerAddrLen); if (outerSocket == -1) { diff --git a/projects/sgauth/web.h b/projects/sgauth/web.h index b734f16b..be9e158d 100644 --- a/projects/sgauth/web.h +++ b/projects/sgauth/web.h @@ -65,8 +65,10 @@ public: void UpdateStat(const LOADSTAT & ls); void Start(); private: - void PrepareNet(); + int SendReply(); + int SendCSS(); + int Redirect(const char * url); #ifdef WIN32 WSADATA wsaData; @@ -74,28 +76,15 @@ private: pthread_t thread; #endif - int SendReply(); - int SendCSS(); - int Redirect(const char * url); - - string dirName[DIR_NUM]; - int res; - int listenSocket; - int outerSocket; - struct sockaddr_in listenAddr; - struct sockaddr_in outerAddr; - int refreshPeriod; + string dirName[DIR_NUM]; + int res; + int listenSocket; + int outerSocket; + int refreshPeriod; - uint32_t listenWebAddr; - LOADSTAT ls; + uint32_t listenWebAddr; + LOADSTAT ls; list messages; - - #ifndef WIN32 - socklen_t outerAddrLen; - #else - int outerAddrLen; - #endif }; //----------------------------------------------------------------------------- - -- 2.44.2