source: cheroxy/trunk/src/main.cpp@ 22

Last change on this file since 22 was 22, checked in by cheese, 11 years ago

#1 more fix main code and release thread

File size: 1.3 KB
Line 
1// LocalProxy.cpp : ÄÜ¼Ö ÀÀ¿ë ÇÁ·Î±×·¥¿¡ ´ëÇÑ ÁøÀÔÁ¡À» Á¤ÀÇÇÕ´Ï´Ù.
2//
3
4#ifdef _WIN32
5# define _CRT_SECURE_NO_WARNINGS
6#endif
7
8#include "CRXSocket.h"
9#include "CRXProxy.h"
10
11#include <iostream>
12#include <iomanip>
13#include <sstream>
14
15#include <stdio.h>
16#include <string.h>
17
18using namespace std;
19
20int main (int argc, char* argv[])
21{
22 int aResult = 0;
23 const unsigned short aPort = 8080;
24
25 CRXSocket aSocket;
26 CRXProxy * aProxy = NULL;
27
28 /*----------------------------------------------------------------*/
29 /*----------------------------------------------------------------
30 * Initialize
31 *----------------------------------------------------------------*/
32 aResult = aSocket.CreateServer (aPort);
33 if (aResult < 0)
34 {
35 cout << "Failed to create server." << endl;
36 return aResult;
37 }
38
39 for (;;)
40 {
41 aResult = aSocket.Accept ();
42 if (aResult < 0)
43 {
44 cout << "Failed to accept." << endl;
45 break;
46 }
47
48 if ((aProxy = CRXProxy::GetNewInstance (aResult)) == NULL)
49 {
50 cout << "Failed to get proxy." << endl;
51 aResult = -1;
52 break;
53 }
54
55 aResult = aProxy->ForwardMT ();
56 if (aResult < 0)
57 {
58 cout << "Failed to forward." << endl;
59 break;
60 }
61 }
62
63 /*----------------------------------------------------------------*/
64 aSocket.Close ();
65
66 return aResult;
67}
Note: See TracBrowser for help on using the repository browser.