12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #pragma once
- #include "WinSocketSystem.h"
- #include "NetOperator.h"
- #include <windows.h>
- #include "log4z.h"
- class TCPServer
- {
- public:
- TCPServer();
- ~TCPServer();
- public:
- int InitNet(const char*ip, int port,INetNotify*pNotify);
- void Stop();
- int SendData(const char*data);
- void SetNotify(INetNotify*pNotify){ m_pNotify = pNotify; }
- protected:
- static unsigned int __stdcall ListenThread(PVOID param);
- static unsigned int __stdcall RecvThread(PVOID param);
- SOCKET sockSrv;
- SOCKET sockCli;
- BOOL m_bexit;
- HANDLE _listen_thread;
- HANDLE _recv_thread;
- INetNotify *m_pNotify;
- LockHelper m_tx_send;
- };
- class TCPClient
- {
- public:
- TCPClient();
- ~TCPClient();
- public:
- int InitNet(const char*ip, int port, INetNotify*pNotify);
- void Stop();
- int SendData(const char*data);
- void SetNotify(INetNotify*pNotify){ m_pNotify = pNotify; }
- protected:
- static unsigned int __stdcall LoopThread(PVOID param);
- SOCKET sockConn;
- BOOL m_bexit;
- HANDLE _loop_thread;
- INetNotify *m_pNotify;
- LockHelper m_tx_send;
- BOOL m_connected;//Á´½ÓÊÇ·ñÒѾÍê³É
- };
|