4 //
\83C
\83\93\83N
\83\8b\81[
\83h
\82Í
\95K
\82¸
\95K
\97v
\82È
\95¨
\82¾
\82¯
5 //
\93à
\95\94\82Å
\97\98\97p
\82·
\82é
\82¾
\82¯
\82Ì
\95¨
\82Í
\83\
\81[
\83X
\82É
\8bL
\8fq
6 // winsock2.h
\82Íwindows.h
\82æ
\82è
\90æ
\82É
\83C
\83\93\83N
\83\8b\81[
\83h
\82µ
\82È
\82¯
\82ê
\82Î
\82È
\82ç
\82È
\82¢
\82ç
\82µ
\82¢
7 //#include <winsock2.h>
9 #include "CRingBuffer.h"
11 //
\8aÖ
\90\94\96¼
\82Í
\83\8d\81[
\83\8f\83L
\83\83\83\81\83\8b\83P
\81[
\83X
\82Æ
\82·
\82é
13 const int MAX_STRING_BUFFER_SIZE = 256;
15 struct CommunicationBuffer
17 char m_Buffer[MAX_STRING_BUFFER_SIZE];
18 //
\8ai
\94[
\82³
\82ê
\82Ä
\82¢
\82é
\95¶
\8e\9a\90\94
27 ////////////////////////////////////////////////////////////////////////////////
29 ////////////////////////////////////////////////////////////////////////////////
30 class CSocket : public CThread
32 ////////////////////////////////////////////////////////////////////////////////
33 //
\83\81\83\93\83o
\95Ï
\90\94
34 ////////////////////////////////////////////////////////////////////////////////
38 sockaddr_in m_SocketAddress;
42 CRingBuffer<CommunicationBuffer> m_Buffer;
44 ////////////////////////////////////////////////////////////////////////////////
45 //
\83R
\83\93\83X
\83g
\83\89\83N
\83^
46 ////////////////////////////////////////////////////////////////////////////////
50 ////////////////////////////////////////////////////////////////////////////////
51 //
\83f
\83X
\83g
\83\89\83N
\83^
52 ////////////////////////////////////////////////////////////////////////////////
56 ////////////////////////////////////////////////////////////////////////////////
57 // static
\8aÖ
\90\94\81A
\83R
\81[
\83\8b\83o
\83b
\83N
\8aÖ
\90\94
58 ////////////////////////////////////////////////////////////////////////////////
59 ////////////////////////////////////////////////////////////////////////////////
60 //
\91\80\8dì
\83\81\83\
\83b
\83h
61 ////////////////////////////////////////////////////////////////////////////////
64 virtual bool initialize();
66 virtual bool uninitialize();
68 virtual bool connection(SOCKET* io_pSocket = NULL, sockaddr_in* io_pSockAddress = NULL);
70 virtual bool disconnection();
72 virtual bool shutdown(unsigned int in_Kind);
74 virtual bool send(const CommunicationBuffer* in_pCommunicationBuffer);
76 virtual bool receive(CommunicationBuffer** out_ppCommunicationBuffer);
79 //
\83X
\83\8c\83b
\83h
\83\8b\81[
\83v
83 ////////////////////////////////////////////////////////////////////////////////
84 //
\91®
\90«
\83\81\83\
\83b
\83h
85 ////////////////////////////////////////////////////////////////////////////////
92 sockaddr* getSocketAddress()
94 return reinterpret_cast<sockaddr*>(&m_SocketAddress);
97 ////////////////////////////////////////////////////////////////////////////////
98 //
\83C
\83e
\83\8c\81[
\83V
\83\87\83\93
99 ////////////////////////////////////////////////////////////////////////////////
100 ////////////////////////////////////////////////////////////////////////////////
102 ////////////////////////////////////////////////////////////////////////////////
104 bool isConnect() const
109 ////////////////////////////////////////////////////////////////////////////////
111 ////////////////////////////////////////////////////////////////////////////////
112 ////////////////////////////////////////////////////////////////////////////////
113 //
\8f\83\90\88\89¼
\91z
\8aÖ
\90\94\81A
\92è
\8b`
\82Ì
\82Ý
\81i
\94ñ
\8eÀ
\91\95\92ñ
\8b\9f\81j
114 ////////////////////////////////////////////////////////////////////////////////
115 ////////////////////////////////////////////////////////////////////////////////
116 //
\93à
\95\94\83N
\83\89\83X
117 ////////////////////////////////////////////////////////////////////////////////