Index: /branches/b0_1_threading/_win/cheroxy.sln
===================================================================
--- /branches/b0_1_threading/_win/cheroxy.sln	(revision 7)
+++ /branches/b0_1_threading/_win/cheroxy.sln	(revision 7)
@@ -0,0 +1,20 @@
+﻿
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cheroxy", "cheroxy\cheroxy.vcproj", "{2B0FC787-D876-4EC1-9C62-F40BE6BA01A9}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{2B0FC787-D876-4EC1-9C62-F40BE6BA01A9}.Debug|Win32.ActiveCfg = Debug|Win32
+		{2B0FC787-D876-4EC1-9C62-F40BE6BA01A9}.Debug|Win32.Build.0 = Debug|Win32
+		{2B0FC787-D876-4EC1-9C62-F40BE6BA01A9}.Release|Win32.ActiveCfg = Release|Win32
+		{2B0FC787-D876-4EC1-9C62-F40BE6BA01A9}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
Index: /branches/b0_1_threading/_win/cheroxy/cheroxy.vcproj
===================================================================
--- /branches/b0_1_threading/_win/cheroxy/cheroxy.vcproj	(revision 7)
+++ /branches/b0_1_threading/_win/cheroxy/cheroxy.vcproj	(revision 7)
@@ -0,0 +1,231 @@
+<?xml version="1.0" encoding="ks_c_5601-1987"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="cheroxy"
+	ProjectGUID="{2B0FC787-D876-4EC1-9C62-F40BE6BA01A9}"
+	RootNamespace="cheroxy"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="196613"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\..\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="2"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				AdditionalIncludeDirectories="..\..\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="1"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="¼Ò½º ÆÄÀÏ"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\CRXHttpMessage.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\CRXHttpRequest.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\CRXHttpResponse.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\CRXSocket.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\main.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Çì´õ ÆÄÀÏ"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\include\CRXHttpMessage.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\include\CRXHttpRequest.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\include\CRXHttpResponse.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\include\CRXSocket.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="¸®¼Ò½º ÆÄÀÏ"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+			<File
+				RelativePath="..\..\src\makefile"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /branches/b0_1_threading/include/CRXHttpMessage.h
===================================================================
--- /branches/b0_1_threading/include/CRXHttpMessage.h	(revision 7)
+++ /branches/b0_1_threading/include/CRXHttpMessage.h	(revision 7)
@@ -0,0 +1,31 @@
+/**
+ * CRXHttpMessage.h
+ */
+#ifndef __CRXHTTPMESSAGE_H__
+#define __CRXHTTPMESSAGE_H__
+
+#include <string>
+
+using namespace std;
+
+class CRXHttpMessage
+{
+protected:
+	std::string	mHttpMessage;
+	std::string	mHttpVersion;
+
+public:
+	CRXHttpMessage				(void);
+
+protected:
+	virtual void	Parse		(void);
+
+public:
+	void			SetMessage	(const char * aHttpMessage);
+	std::string		GetMessage	(void) const;
+
+								operator const char *	(void) const;
+	virtual CRXHttpMessage &	operator =				(const char * aHttpMessage);
+};
+
+#endif // #ifndef __CRXHTTPMESSAGE_H__
Index: /branches/b0_1_threading/include/CRXHttpRequest.h
===================================================================
--- /branches/b0_1_threading/include/CRXHttpRequest.h	(revision 7)
+++ /branches/b0_1_threading/include/CRXHttpRequest.h	(revision 7)
@@ -0,0 +1,38 @@
+/**
+ * CRXHttpRequest.h
+ */
+#ifndef __CRXHTTPREQUEST_H__
+#define __CRXHTTPREQUEST_H__
+
+#include "CRXHttpMessage.h"
+
+class CRXHttpRequest : public CRXHttpMessage
+{
+private:
+	std::string	mMethod;
+	std::string	mUrl;
+	std::string	mHttpVersion;
+
+	std::string	mProtocol;
+	std::string	mHost;
+	int			mPort;
+
+public:
+	CRXHttpRequest					(void);
+
+private:
+	void				Parse		(void);
+
+public:
+	void				SetRequest	(const char * aHttpRequest);
+	std::string			GetRequest	(void) const;
+
+	CRXHttpRequest &	operator =	(const char * aHttpRequest);
+
+public:
+	std::string			GetURL		(void) const;
+	std::string			GetHost		(void) const;
+	int					GetPort		(void) const;
+};
+
+#endif // #ifndef __CRXHTTPREQUEST_H__
Index: /branches/b0_1_threading/include/CRXHttpResponse.h
===================================================================
--- /branches/b0_1_threading/include/CRXHttpResponse.h	(revision 7)
+++ /branches/b0_1_threading/include/CRXHttpResponse.h	(revision 7)
@@ -0,0 +1,31 @@
+/**
+ * CRXHttpResponse.h
+ */
+#ifndef __CRXHTTPRESPONSE_H__
+#define __CRXHTTPRESPONSE_H__
+
+#include "CRXHttpMessage.h"
+
+class CRXHttpResponse : public CRXHttpMessage
+{
+private:
+	int			mStatusCode;
+	std::string	mStatusString;
+
+public:
+	CRXHttpResponse					(void);
+
+private:
+	void				Parse		(void);
+
+public:
+	void				SetResponse	(const char * aHttpResponse);
+	std::string			GetResponse	(void) const;
+
+	CRXHttpResponse &	operator =	(const char * aHttpResponse);
+
+public:
+	int					GetStatusCode (void) const;
+};
+
+#endif // #ifndef __CRXHTTPRESPONSE_H__
Index: /branches/b0_1_threading/include/CRXMutex.h
===================================================================
--- /branches/b0_1_threading/include/CRXMutex.h	(revision 7)
+++ /branches/b0_1_threading/include/CRXMutex.h	(revision 7)
@@ -0,0 +1,26 @@
+/*
+ * CRXMutex.h
+ */
+
+#ifdef _WIN32
+# include <Windows.h>
+# define CRX_MUTEX	HANDLE
+#else
+# include <pthread.h>
+# define CRX_MUTEX	pthread_mutex_t
+#endif
+
+class CRXMutex
+{
+private:
+	CRX_MUTEX mMutex;
+
+public:
+	CRXMutex			(void);
+	~CRXMutex			(void);
+
+public:
+	int		Create		(void);
+	void	Lock		(void);
+	void	Unlock		(void);
+};
Index: /branches/b0_1_threading/include/CRXSocket.h
===================================================================
--- /branches/b0_1_threading/include/CRXSocket.h	(revision 7)
+++ /branches/b0_1_threading/include/CRXSocket.h	(revision 7)
@@ -0,0 +1,115 @@
+/**
+ * CRXSocket.h
+ */
+#ifndef __CRXSOCKET_H__
+#define __CRXSOCKET_H__
+
+#ifdef WIN32
+# include <WinSock2.h>
+#else
+# include <netinet/in.h>
+# include <sys/socket.h>
+# include <arpa/inet.h>
+# include <netdb.h>
+#endif
+
+#include <string>
+
+using namespace std;
+
+typedef struct sockaddr		stSockAddr;
+typedef struct sockaddr_in	stSockAddrIn;
+typedef unsigned short		ushort;
+typedef unsigned int		uint;
+
+#define ERROR_TCPSOCKET							-1000
+
+#define ERROR_TCPSOCKET_FAILED_TO_INITIALIZE	ERROR_TCPSOCKET - 1
+#define ERROR_TCPSOCKET_ALREADY_IN_USE			ERROR_TCPSOCKET - 2
+#define ERROR_TCPSOCKET_FAILED_TO_CREATE_SOCKET	ERROR_TCPSOCKET - 3
+#define ERROR_TCPSOCKET_FAILED_TO_GET_HOSTNAME	ERROR_TCPSOCKET - 4
+#define ERROR_TCPSOCKET_FAILED_TO_CONNECT		ERROR_TCPSOCKET - 5
+#define ERROR_TCPSOCKET_FAILED_TO_BIND			ERROR_TCPSOCKET - 6
+#define ERROR_TCPSOCKET_FAILED_TO_LISTEN		ERROR_TCPSOCKET - 7
+#define ERROR_TCPSOCKET_FAILED_TO_ACCEPT		ERROR_TCPSOCKET - 8
+#define ERROR_TCPSOCKET_FAILED_TO_SEND			ERROR_TCPSOCKET - 9
+#define ERROR_TCPSOCKET_FAILED_TO_RECEIVE		ERROR_TCPSOCKET - 10
+#define ERROR_TCPSOCKET_NOT_READY				ERROR_TCPSOCKET - 11
+
+class CRXSocket
+{
+private:
+	static bool		mInitialized;
+	stSockAddrIn	mAddress;
+	int				mSocket;
+
+private:
+	/**
+	 * create socket.
+	 * @return success : socket id, failed : -1.
+	 */
+	int			CreateSocket	(void);
+
+	/**
+	 * check socket status.
+	 * @return available : true, else : false.
+	 */
+	inline bool	IsCreated		(void) const;
+
+	inline bool	IsReady			(void) const;
+
+	/**
+	 * static functions
+	 */
+	static int	Initialize		(void);
+
+	static bool	IsInitialized	(void);
+
+	static void	Finalize		(void);
+
+
+public:
+	/**
+	 * common functions
+	 */
+	CRXSocket					(int aSocket = 0);
+
+	~CRXSocket					(void);
+
+	void		Attach			(int aSocket);
+
+	int			Detach			(void);
+
+	void		Close			(void);
+
+				operator int	(void) const;
+
+	CRXSocket	& operator =	(int aSocket);
+
+	/**
+	 * for server
+	 */
+	int CreateServer			(ushort			aPort,
+								 int			aBacklog = 5,
+								 stSockAddrIn	* aAddress = NULL);
+
+	int Accept					(stSockAddrIn	* aRemoteAddress = NULL,
+								 int			* aAddressLength = NULL);
+
+	/**
+	 * for client
+	 */
+	int Connect					(std::string	aUrl,
+								 ushort			aPort);
+
+	/**
+	 * for communication
+	 */
+	int Send					(char	* aBuffer,
+								 int	aSize);
+
+	int Receive					(char	* aBuffer,
+								 int	aSize);
+};
+
+#endif // #ifndef __CRXSOCKET_H__
Index: /branches/b0_1_threading/include/CRXThread.h
===================================================================
--- /branches/b0_1_threading/include/CRXThread.h	(revision 7)
+++ /branches/b0_1_threading/include/CRXThread.h	(revision 7)
@@ -0,0 +1,34 @@
+/*
+ * CRXThread.h
+ */
+
+#ifdef _WIN32
+# include <windows.h>
+# include <process.h>
+# define CRX_THREAD_TYPE			void
+#else
+# include <pthread.h>
+# define CRX_THREAD_TYPE			void *
+#endif
+
+class CRXThread
+{
+private:
+	bool				mIsThreadRunnable;
+
+	CRX_THREAD_TYPE		(* mCallback) (void * aArgs);
+	void				* mThreadArg;
+
+public:
+	CRXThread			(void);
+
+public:
+	void	Create		(void);
+
+	int		Run			(void);
+	void	Stop		(void);
+	void	SetRunnable	(bool aIsRunnable);
+	bool	IsRunnable	(void) const;
+};
+
+
Index: /branches/b0_1_threading/src/CRXHttpMessage.cpp
===================================================================
--- /branches/b0_1_threading/src/CRXHttpMessage.cpp	(revision 7)
+++ /branches/b0_1_threading/src/CRXHttpMessage.cpp	(revision 7)
@@ -0,0 +1,53 @@
+/**
+ * CRXHttpMessage.cpp
+ */
+#ifdef _WIN32
+# pragma warning (disable:4996)
+#endif
+
+#include "CRXHttpMessage.h"
+
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+
+CRXHttpMessage::CRXHttpMessage (void)
+	: mHttpMessage	(""),
+	  mHttpVersion	("")
+{
+}
+
+void
+CRXHttpMessage::SetMessage (const char * aHttpMessage)
+{
+	if (aHttpMessage == NULL)
+		return ;
+
+	mHttpMessage.clear ();
+	mHttpMessage.assign (aHttpMessage);
+
+	this->Parse ();
+}
+
+std::string
+CRXHttpMessage::GetMessage (void) const
+{
+	return mHttpMessage;
+}
+
+void
+CRXHttpMessage::Parse (void)
+{
+}
+
+CRXHttpMessage::operator const char * (void) const
+{
+	return mHttpMessage.c_str ();
+}
+
+CRXHttpMessage &
+CRXHttpMessage::operator = (const char * aHttpMessage)
+{
+	SetMessage (aHttpMessage);
+	return *this;
+}
Index: /branches/b0_1_threading/src/CRXHttpRequest.cpp
===================================================================
--- /branches/b0_1_threading/src/CRXHttpRequest.cpp	(revision 7)
+++ /branches/b0_1_threading/src/CRXHttpRequest.cpp	(revision 7)
@@ -0,0 +1,102 @@
+/**
+ * CRXHttpRequest.cpp
+ */
+#ifdef _WIN32
+# pragma warning (disable:4996)
+#endif
+
+#include "CRXHttpRequest.h"
+
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+
+CRXHttpRequest::CRXHttpRequest (void)
+	: mMethod		(""),
+	  mUrl			(""),
+	  mHttpVersion	(""),
+	  mProtocol		(""),
+	  mHost			(""),
+	  mPort			(0)
+{
+}
+
+void
+CRXHttpRequest::SetRequest (const char * aHttpRequest)
+{
+	SetMessage (aHttpRequest);
+}
+
+std::string
+CRXHttpRequest::GetRequest (void) const
+{
+	return GetMessage ();
+}
+
+std::string
+CRXHttpRequest::GetURL (void) const
+{
+	return mUrl;
+}
+
+std::string
+CRXHttpRequest::GetHost (void) const
+{
+	return mHost;
+}
+
+int
+CRXHttpRequest::GetPort (void) const
+{
+	return mPort;
+}
+
+CRXHttpRequest &
+CRXHttpRequest::operator = (const char * aHttpMessage)
+{
+	SetRequest (aHttpMessage);
+	return *this;
+}
+
+void
+CRXHttpRequest::Parse (void)
+{
+	std::string	aHttpRequestUri		= "";
+
+	char		aMethod[64]			= {0x00, };
+	char		aUrl[1024]			= {0x00, };
+	char		aHttpVersion[64]	= {0x00, };
+
+	char		aProtocol[32]		= {0x00, };
+	char		aHostBuffer[512]	= {0x00, };
+	char		aHost[512]			= {0x00, };
+	char		aPortBuffer[32]		= {0x00, };
+	int			aPort				= 0;
+
+	/*----------------------------------------------------------------*/
+	aHttpRequestUri = GetRequest ().substr (0, mHttpMessage.find ('\r'));
+
+	/*----------------------------------------------------------------
+	 * 1. separate first line to <METHOD>, <URL> and <VERSION>
+	 *----------------------------------------------------------------*/
+	sscanf (aHttpRequestUri.c_str (), "%[^ ] %[^ ] %[^ ]\r\n", aMethod, aUrl, aHttpVersion);
+	mMethod.assign (aMethod);
+	mUrl.assign (aUrl);
+	mHttpVersion.assign (aHttpVersion);
+
+	/*----------------------------------------------------------------
+	 * 2. separate <URL> to <PROTOCOL> and <HOST>
+	 *----------------------------------------------------------------*/
+	sscanf (mUrl.c_str (), "%[^://]://%[^/]", aProtocol, aHostBuffer);
+	mProtocol.assign (aProtocol);
+
+	/*----------------------------------------------------------------
+	 * 3. separate <HOST> to <HOSTNAME>:<PORT>
+	 *----------------------------------------------------------------*/
+	sscanf (aHostBuffer, "%[^:]:%s", aHost, aPortBuffer);
+	mHost.assign (aHost);
+	aPort = atoi (aPortBuffer);
+
+	mPort = aPort == 0 ? 80 : aPort;
+	/*----------------------------------------------------------------*/
+}
Index: /branches/b0_1_threading/src/CRXHttpResponse.cpp
===================================================================
--- /branches/b0_1_threading/src/CRXHttpResponse.cpp	(revision 7)
+++ /branches/b0_1_threading/src/CRXHttpResponse.cpp	(revision 7)
@@ -0,0 +1,65 @@
+/**
+ * CRXHttpResponse.cpp
+ */
+#ifdef _WIN32
+# pragma warning (disable:4996)
+#endif
+
+#include "CRXHttpResponse.h"
+
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+
+CRXHttpResponse::CRXHttpResponse (void)
+	: mStatusCode	(0)
+{
+}
+
+void
+CRXHttpResponse::SetResponse (const char * aHttpResponse)
+{
+	SetMessage (aHttpResponse);
+}
+
+std::string
+CRXHttpResponse::GetResponse (void) const
+{
+	return GetMessage ();
+}
+
+CRXHttpResponse &
+CRXHttpResponse::operator = (const char * aHttpMessage)
+{
+	SetMessage (aHttpMessage);
+	return *this;
+}
+
+void
+CRXHttpResponse::Parse (void)
+{
+	std::string	aHttpStatus		= "";
+
+	char		aStatusCode[64]		= {0x00, };
+	char		aStatusString[64]	= {0x00, };
+	char		aHttpVersion[64]	= {0x00, };
+
+	/*----------------------------------------------------------------*/
+	aHttpStatus = GetResponse ().substr (0, mHttpMessage.find ('\r'));
+
+	/*----------------------------------------------------------------
+	 * 1. separate first line to <METHOD>, <URL> and <VERSION>
+	 *----------------------------------------------------------------*/
+	sscanf (aHttpStatus.c_str (), "%[^ ] %[^ ] %[^ ]\r\n", aHttpVersion, aStatusCode, aStatusString);
+	mHttpVersion.assign (aHttpVersion);
+	mStatusString.assign (aStatusString);
+	mStatusCode = atoi (aStatusCode);
+
+	/*----------------------------------------------------------------*/
+}
+
+int
+CRXHttpResponse::GetStatusCode (void) const
+{
+	return mStatusCode;
+}
Index: /branches/b0_1_threading/src/CRXMutex.cpp
===================================================================
--- /branches/b0_1_threading/src/CRXMutex.cpp	(revision 7)
+++ /branches/b0_1_threading/src/CRXMutex.cpp	(revision 7)
@@ -0,0 +1,48 @@
+
+#include "CRXMutex.h"
+
+CRXMutex::CRXMutex (void)
+{
+#ifdef _WIN32
+	mMutex = NULL;
+#endif
+}
+
+CRXMutex::~CRXMutex (void)
+{
+	this->Unlock ();
+#ifdef _WIN32
+#else
+#endif
+}
+
+int CRXMutex::Create ()
+{
+#ifdef _WIN32
+	if ((mMutex = ::CreateMutexA(NULL, FALSE, NULL)) == NULL)
+		return -1;
+#else
+	pthread_mutex_init (&mMutex, NULL);
+#endif
+
+	return 0;
+}
+
+void CRXMutex::Lock (void)
+{
+#ifdef _WIN32
+	::WaitForSingleObject (mMutex, INFINITE);
+#else
+	pthread_mutex_lock (&mMutex);
+#endif
+}
+
+void CRXMutex::Unlock (void)
+{
+#ifdef _WIN32
+	if (mMutex != NULL)
+		::ReleaseMutex(mMutex);
+#else
+	pthread_mutex_unlock (&mMutex);
+#endif
+}
Index: /branches/b0_1_threading/src/CRXSocket.cpp
===================================================================
--- /branches/b0_1_threading/src/CRXSocket.cpp	(revision 7)
+++ /branches/b0_1_threading/src/CRXSocket.cpp	(revision 7)
@@ -0,0 +1,307 @@
+/**
+ * CRXSocket.cpp
+ */
+#include "CRXSocket.h"
+
+#include <string.h>
+
+#ifdef _WIN32
+# pragma comment (lib, "ws2_32.lib")
+# define close(__socket) closesocket(__socket)
+typedef int socklen_t;
+#endif
+
+bool CRXSocket::mInitialized = false;
+
+CRXSocket::CRXSocket (int aSocket)
+	: mSocket (aSocket)
+{
+	/*----------------------------------------------------------------*/
+	memset ((void *)&mAddress, 0x0, sizeof (stSockAddrIn));
+
+	if (!CRXSocket::IsInitialized ())
+		CRXSocket::Initialize ();
+	/*----------------------------------------------------------------*/
+}
+
+CRXSocket::~CRXSocket (void)
+{
+	/*----------------------------------------------------------------*/
+	Close ();
+	/*----------------------------------------------------------------*/
+}
+
+void
+CRXSocket::Attach (int aSocket)
+{
+	/*----------------------------------------------------------------*/
+	mSocket = aSocket;
+	/*----------------------------------------------------------------*/
+}
+
+int
+CRXSocket::Detach (void)
+{
+	int aSocket = mSocket;
+
+	/*----------------------------------------------------------------*/
+	mSocket = 0;
+
+	/*----------------------------------------------------------------*/
+	return aSocket;
+}
+
+void
+CRXSocket::Close (void)
+{
+	/*----------------------------------------------------------------*/
+	if (mSocket <= 0)
+		return ;
+
+	close (mSocket);
+	mSocket = 0;
+	/*----------------------------------------------------------------*/
+}
+
+CRXSocket::operator int (void) const
+{
+	/*----------------------------------------------------------------*/
+	/*----------------------------------------------------------------*/
+	return mSocket;
+}
+
+CRXSocket &
+CRXSocket::operator = (int aSocket)
+{
+	/*----------------------------------------------------------------*/
+	Attach (aSocket);
+	/*----------------------------------------------------------------*/
+	return *this;
+}
+
+int
+CRXSocket::Initialize (void)
+{
+	int aResult = 0;
+
+	/*----------------------------------------------------------------*/
+	if (CRXSocket::IsInitialized ())
+		return aResult;
+
+#ifdef WIN32
+	WSADATA aWinSockData;
+	
+	aResult = WSAStartup (MAKEWORD (2, 0), &aWinSockData);
+	if (aResult != 0)
+	{
+		return ERROR_TCPSOCKET_FAILED_TO_INITIALIZE;
+	}
+#endif
+
+	mInitialized = true;
+
+	/*----------------------------------------------------------------*/
+	return aResult;
+}
+
+void
+CRXSocket::Finalize (void)
+{
+	/*----------------------------------------------------------------*/
+#ifdef WIN32
+	WSACleanup ();
+#endif
+	/*----------------------------------------------------------------*/
+}
+
+bool
+CRXSocket::IsInitialized (void)
+{
+	/*----------------------------------------------------------------*/
+	/*----------------------------------------------------------------*/
+	return mInitialized;
+}
+
+bool
+CRXSocket::IsReady (void) const
+{
+	/*----------------------------------------------------------------*/
+	/*----------------------------------------------------------------*/
+	return IsInitialized () && IsCreated ();
+}
+
+bool
+CRXSocket::IsCreated (void) const
+{
+	/*----------------------------------------------------------------*/
+	/*----------------------------------------------------------------*/
+	return mSocket > 0 ? true : false;
+}
+
+int
+CRXSocket::CreateSocket (void)
+{
+	int aResult = -1;
+
+	/*----------------------------------------------------------------*/
+	if (!IsInitialized () || IsCreated ())
+		return ERROR_TCPSOCKET_ALREADY_IN_USE;
+
+	aResult = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
+	if (aResult < 0)
+	{
+	}
+
+	mSocket = aResult;
+
+	/*----------------------------------------------------------------*/
+	return aResult;
+}
+
+int
+CRXSocket::Connect (std::string	aUrl,
+					ushort		aPort)
+{
+	int				aResult = -1;
+	struct hostent	* aHostEnt;
+
+	/*----------------------------------------------------------------*/
+	aResult = CreateSocket ();
+	if (aResult < 0)
+	{
+		return aResult;
+	}
+
+	mAddress.sin_family			= AF_INET;
+	mAddress.sin_port			= htons (aPort);
+	mAddress.sin_addr.s_addr	= inet_addr (aUrl.c_str ());
+
+	if (mAddress.sin_addr.s_addr == (unsigned int)-1)
+	{
+		aHostEnt = gethostbyname (aUrl.c_str ());
+		if (aHostEnt == NULL)
+		{
+			return ERROR_TCPSOCKET_FAILED_TO_GET_HOSTNAME;
+		}
+		mAddress.sin_family = aHostEnt->h_addrtype;
+		memcpy (&(mAddress.sin_addr.s_addr), aHostEnt->h_addr, aHostEnt->h_length);
+	}
+
+	aResult = connect (mSocket, (stSockAddr*) &mAddress, sizeof (mAddress));
+	if (aResult < 0)
+	{
+		return ERROR_TCPSOCKET_FAILED_TO_CONNECT;
+	}
+
+	/*----------------------------------------------------------------*/
+	return aResult;
+}
+
+int
+CRXSocket::CreateServer (ushort			aPort,
+						 int			aBacklog,
+						 stSockAddrIn	* aAddress)
+{
+	int aResult = -1;
+
+	/*----------------------------------------------------------------*/
+	aResult = CreateSocket ();
+	if (aResult < 0)
+	{
+		return aResult;
+	}
+
+	mAddress.sin_family		= AF_INET;
+	mAddress.sin_addr.s_addr= htonl (INADDR_ANY);
+	mAddress.sin_port		= htons (aPort);
+
+	aResult = bind (mSocket, (stSockAddr *)&mAddress, sizeof (stSockAddr));
+	if (aResult < 0)
+	{
+		return ERROR_TCPSOCKET_FAILED_TO_BIND;
+	}
+
+	aResult = listen (mSocket, aBacklog);
+	if (aResult < 0)
+	{
+		return ERROR_TCPSOCKET_FAILED_TO_LISTEN;
+	}
+
+	if (aAddress != NULL)
+	{
+		memset ((void *)aAddress, 0x0, sizeof (stSockAddrIn));
+		memcpy ((void *)aAddress, (void *)&mAddress, sizeof (stSockAddrIn));
+	}
+
+	/*----------------------------------------------------------------*/
+	return aResult;
+}
+
+int
+CRXSocket::Accept (stSockAddrIn * aRemoteAddress,
+				   int			* aAddressLength)
+{
+	int				aResult = -1;
+
+	stSockAddrIn	aAddress;
+	socklen_t		aLength = sizeof (aAddress);
+
+	/*----------------------------------------------------------------*/
+	if (!IsReady ())		return ERROR_TCPSOCKET_NOT_READY;
+
+	aResult = accept (mSocket, (stSockAddr *) &aAddress, &aLength);
+	if (aResult < 0)
+	{
+		return aResult;
+	}
+
+	if (aRemoteAddress != NULL)
+	{
+		memset ((void *)aRemoteAddress, 0x0, sizeof (stSockAddrIn));
+		memcpy ((void *)aRemoteAddress, (void *)&aAddress, sizeof (stSockAddrIn));
+	}
+
+	if (aAddressLength != NULL)
+		*aAddressLength = aLength;
+
+	/*----------------------------------------------------------------*/
+	return aResult;
+}
+
+int
+CRXSocket::Send (char	* aBuffer,
+				 int	aSize)
+{
+	int aResult = -1;
+
+	/*----------------------------------------------------------------*/
+	if (!IsReady ())		return ERROR_TCPSOCKET_NOT_READY;
+
+	aResult = send (mSocket, aBuffer, aSize, 0);
+	if (aResult != aSize)
+	{
+		return ERROR_TCPSOCKET_FAILED_TO_SEND;
+	}
+
+	/*----------------------------------------------------------------*/
+	return aResult;
+}
+
+int
+CRXSocket::Receive (char	* aBuffer,
+					int		aSize)
+{
+	int aResult = -1;
+
+	/*----------------------------------------------------------------*/
+	if (!IsReady ())		return ERROR_TCPSOCKET_NOT_READY;
+
+	aResult = recv (mSocket, aBuffer, aSize, 0);
+	if (aResult < 0)
+	{
+		return ERROR_TCPSOCKET_FAILED_TO_RECEIVE;
+	}
+
+	/*----------------------------------------------------------------*/
+	return aResult;
+}
Index: /branches/b0_1_threading/src/CRXThread.cpp
===================================================================
--- /branches/b0_1_threading/src/CRXThread.cpp	(revision 7)
+++ /branches/b0_1_threading/src/CRXThread.cpp	(revision 7)
@@ -0,0 +1,12 @@
+/*
+ * CRXThread.cpp
+ */
+#include "CRXThread.h"
+
+CRXThread::CRXThread (void)
+	: mIsThreadRunnable	(false),
+	  mCallback			(NULL),
+	  mThreadArg		(NULL)
+{
+}
+
Index: /branches/b0_1_threading/src/main.cpp
===================================================================
--- /branches/b0_1_threading/src/main.cpp	(revision 7)
+++ /branches/b0_1_threading/src/main.cpp	(revision 7)
@@ -0,0 +1,210 @@
+// LocalProxy.cpp : ÄÜ¼Ö ÀÀ¿ë ÇÁ·Î±×·¥¿¡ ´ëÇÑ ÁøÀÔÁ¡À» Á¤ÀÇÇÕ´Ï´Ù.
+//
+
+#ifdef _WIN32
+# define _CRT_SECURE_NO_WARNINGS
+# include <process.h>
+#else
+# include <errno.h>
+#endif
+
+#include "CRXSocket.h"
+#include "CRXHttpRequest.h"
+#include "CRXHttpResponse.h"
+
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+
+#include <stdio.h>
+#include <string.h>
+
+using namespace std;
+
+/*-----------------------------------------------------------------*/
+int CRXCreateThread	(int (* aThreadFunc) (void *), void * aThreadArg);
+int CRXProxyThread	(void * aThreadArg);
+
+/* error */
+#ifdef _WIN32
+# define CRX_ERROR()		GetLastError ()
+# ifndef __func__
+#  define __func__			__FUNCTION__
+# endif
+#else
+# define CRX_ERROR()		errno
+#endif
+
+#define CRX_PRINT_ERROR(__code, __message)																\
+	do {																								\
+		char __error[1024] = {0x00, };																	\
+		ostringstream __stream;																			\
+		__stream << __message;																			\
+		string __string = __stream.str ();																\
+		sprintf (__error, "[%s][%d] %d : %s\n", __func__, __LINE__, __code, __string.c_str ());			\
+		cout << __error;																				\
+	} while (0)
+
+typedef struct __crx_proxy_thread_argument__
+{
+	int mSocket;
+} CRXProxyThreadArgs;
+/*----------------------------------------------------------------*/
+
+int main (int argc, char* argv[])
+{
+	int					aResult	= 0;
+	const ushort		aPort	= 8080;
+
+	CRXSocket			aSocket;
+	CRXProxyThreadArgs	* aThreadArg;
+
+	/*----------------------------------------------------------------*/
+	/*----------------------------------------------------------------
+	 * Initialize
+	 *----------------------------------------------------------------*/
+	aResult = aSocket.CreateServer (aPort);
+	if (aResult < 0)
+	{
+		CRX_PRINT_ERROR (aResult, "failed to create server");
+		return aResult;
+	}
+
+	for (;;)
+	{
+		aResult = aSocket.Accept ();
+		if (aResult < 0)
+		{
+			CRX_PRINT_ERROR (aResult, "failed to accept");
+			break;
+		}
+
+		if ((aThreadArg = new(std::nothrow) CRXProxyThreadArgs) == NULL)
+		{
+			aResult = -1;
+			break;
+		}
+
+		memset (aThreadArg, 0x0, sizeof (CRXProxyThreadArgs));
+		aThreadArg->mSocket = aResult;
+
+		aResult = CRXCreateThread (CRXProxyThread, aThreadArg);
+		if (aResult < 0)
+		{
+			aResult = CRX_ERROR ();
+			CRX_PRINT_ERROR (aResult, "failed to create thread");
+			break;
+		}
+	}
+
+	/*----------------------------------------------------------------*/
+	aSocket.Close ();
+
+	return aResult;
+}
+
+int
+CRXCreateThread	(int (* aThreadFunc) (void *), void * aThreadArg)
+{
+#ifdef _WIN32
+	return _beginthread ((void (*) (void *))aThreadFunc, 0, aThreadArg);
+#else
+	pthread_t aThreadID = 0;
+
+	return pthread_create (&aThreadID, NULL, (void * (*) (void *))aThreadFunc, aThreadArg);
+#endif
+}
+
+int
+CRXProxyThread (void * aThreadArg)
+{
+	int				aResult			= 0;
+	int				aReceivedSize	= 0;
+	int				aSentSize		= 0;
+
+	const uint		aBufferSize		= 1024 * 64;
+	char			aBuffer[aBufferSize] = {0x00, };
+
+	CRXHttpRequest	aHttpRequest;
+	CRXHttpResponse	aHttpResponse;
+	string			aUrl	= "";
+	string			aHost	= "";
+	int				aPort	= 0;
+
+	CRXSocket		aWebServer;
+	CRXSocket		aWebBrowser	= ((CRXProxyThreadArgs *)aThreadArg)->mSocket;
+
+	bool			aIsMoreRequest = false;
+	/*----------------------------------------------------------------*/
+	delete (CRXProxyThreadArgs *)aThreadArg;
+
+	do
+	{
+		/* BROWSER --- request ---> [PROXY]                  SERVER */
+		aReceivedSize = aWebBrowser.Receive (aBuffer, aBufferSize);
+		if (aReceivedSize < 0)
+		{
+			CRX_PRINT_ERROR (aReceivedSize, "failed to receive from client");
+			aResult = CRX_ERROR ();
+			return aResult;
+		}
+
+		/* BROWSER ?--- waiting --- [PROXY] --- connect ---> SERVER */
+		if (!aWebServer)
+		{
+			/* parse http request */
+			aHttpRequest = aBuffer;
+
+			/* connect */
+			aResult = aWebServer.Connect (aHttpRequest.GetHost (), aHttpRequest.GetPort ());
+			if (aResult < 0)
+			{
+				CRX_PRINT_ERROR (aResult, "failed to connect to server <" << aHost << ":" << aPort << ">");
+				aResult = CRX_ERROR ();
+				return aResult;
+			}
+		}
+
+		/* BROWSER ?--- waiting --- [PROXY] --- request ---> SERVER */
+		aSentSize = aWebServer.Send (aBuffer, aReceivedSize);
+		if (aSentSize != aReceivedSize)
+		{
+			CRX_PRINT_ERROR (aResult, "failed to send to server");
+			aResult = CRX_ERROR ();
+			return aResult;
+		}
+
+		/* BROWSER <--- response--- [PROXY] <--- response--- SERVER */
+		for (;;)
+		{
+			memset (aBuffer, 0x00, aBufferSize);
+
+			aReceivedSize = aWebServer.Receive (aBuffer, aBufferSize);
+			if (aReceivedSize < 0)
+			{
+				CRX_PRINT_ERROR (aReceivedSize, "failed to receive");
+				aResult = CRX_ERROR ();
+				break;
+			}
+			else if (aReceivedSize == 0)
+			{
+				aResult = 0;
+				break;
+			}
+
+			aSentSize = aWebBrowser.Send (aBuffer, aReceivedSize);
+			if (aSentSize != aReceivedSize)
+			{
+				CRX_PRINT_ERROR (aSentSize, "failed to send");
+				aResult = CRX_ERROR ();
+				break;
+			}
+		}
+	} while (aIsMoreRequest);
+
+	/*----------------------------------------------------------------*/
+	aWebBrowser.Close ();
+	aWebServer.Close ();
+
+	return aResult;
+}
Index: /branches/b0_1_threading/src/makefile
===================================================================
--- /branches/b0_1_threading/src/makefile	(revision 7)
+++ /branches/b0_1_threading/src/makefile	(revision 7)
@@ -0,0 +1,67 @@
+
+#----------------------------------------------------------
+# platform
+#----------------------------------------------------------
+OS	= 32
+
+ifeq ($(OS), 64)
+	PLATFORM	= -m64
+else
+	PLATFORM	= -m32
+endif
+
+#----------------------------------------------------------
+# env
+#----------------------------------------------------------
+FILES			=	\
+					CRXHttpMessage		\
+					CRXHttpRequest		\
+					CRXHttpResponse		\
+					CRXSocket			\
+					CRXMutex			\
+					CRXThread			\
+					main				\
+
+CXX				= g++
+LD				= g++
+CXXDEFS			= 
+CXXFLAGS		= $(PLATFORM) -fPIC -Wall -Wcast-align -c -g
+LDFLAGS			= $(PLATFORM)
+SHARED_FLAGS	= $(PLATFORM) -shared
+
+SOURCE_TYPE		= cpp
+TARGET_PATH		= ../_build
+OBJ_PATH		= ../_obj
+TARGET			= $(TARGET_PATH)/cheroxy.ex
+SRCS			= $(addsuffix .$(SOURCE_TYPE),$(FILES))
+OBJS			= $(addprefix $(OBJ_PATH)/,$(addsuffix .o,$(FILES)))
+
+INCLUDES		= -I../include
+LIBS			= -lpthread
+
+#----------------------------------------------------------
+# label
+#----------------------------------------------------------
+all: $(OBJ_PATH) $(TARGET_PATH) $(TARGET)
+	@echo ========== Complete CHEROXY compilation ==========
+$(TARGET_PATH): dummy
+	@if [ ! -d $@ ] ; then mkdir $@ ; fi
+$(OBJ_PATH): dummy
+	@if [ ! -d $@ ] ; then mkdir $@ ; fi
+
+# link
+$(TARGET): $(OBJS)
+	$(LD) $(LDFLAGS) -o $@ $? $(LIBS)
+
+# compile
+$(OBJ_PATH)/%.o: %.$(SOURCE_TYPE)
+	$(CXX) $(CXXFLAGS) $(CXXDEFS) $(INCLUDES) -o $@ $?
+
+clean: dummy
+	rm -rf $(TARGET_PATH) $(OBJ_PATH)
+
+dummy:
+
+test: $(TARGET)
+	$(TARGET)
+
