123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- //---------------------------------------------------------------------------
- #ifndef FrmNetworkFH
- #define FrmNetworkFH
- //---------------------------------------------------------------------------
- #include <Classes.hpp>
- #include <Controls.hpp>
- #include <StdCtrls.hpp>
- #include <Forms.hpp>
- #include <winsock2.h>
- #include <ExtCtrls.hpp>
- //---------------------------------------------------------------------------
- #define WM_SOCKET_ACCEPT (WM_USER + 100)
- #define WM_SOCKET_SELECT (WM_USER + 101)
- //---------------------------------------------------------------------------
- class TFrmNetwork : public TForm
- {
- __published: // IDE-managed Components
- TMemo *reMsg;
- TPanel *Panel1;
- TPanel *Panel2;
- TCheckBox *chkLogPause;
- TButton *btnClear;
- TButton *btnCopy;
- void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
- void __fastcall FormDestroy(TObject *Sender);
- void __fastcall btnCopyClick(TObject *Sender);
- void __fastcall btnClearClick(TObject *Sender);
- private: // User declarations
- bool FInitialize;
- bool FStart;
- int FLastErr;
- SOCKET FListenSock;
- AnsiString FErrorString;
- bool __fastcall InitSock();
- void __fastcall TermSock();
- int __fastcall CloseSocket(SOCKET& ASock);
- int __fastcall SocketError(int AError=-1);
- public:
- bool __fastcall Start();
- void __fastcall Stop();
- public: // User declarations
- __fastcall TFrmNetwork(TComponent* Owner);
- void LogWrite(void* ALog);
- int LogWrite(int ALogKind, char *AFmt, ...);
- void __fastcall OnAcceptClient(TMessage &Msg);
- void __fastcall OnSelectClient(TMessage &Msg);
- BEGIN_MESSAGE_MAP
- MESSAGE_HANDLER(WM_SOCKET_ACCEPT, TMessage, OnAcceptClient)
- MESSAGE_HANDLER(WM_SOCKET_SELECT, TMessage, OnSelectClient)
- END_MESSAGE_MAP(TForm)
- public:
- __property int LastError = { read = FLastErr };
- __property AnsiString ErrorString = { read = FErrorString };
- __property SOCKET Socket = { read = FListenSock };
- };
- //---------------------------------------------------------------------------
- extern PACKAGE TFrmNetwork *FrmNetwork;
- //---------------------------------------------------------------------------
- #endif
|