12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- //---------------------------------------------------------------------------
- #ifndef FrmNetworkFH
- #define FrmNetworkFH
- //---------------------------------------------------------------------------
- #include <Classes.hpp>
- #include <Controls.hpp>
- #include <StdCtrls.hpp>
- #include <Forms.hpp>
- #include <winsock2.h>
- //---------------------------------------------------------------------------
- #define WM_SOCKET_ACCEPT (WM_USER + 100)
- #define WM_SOCKET_SELECT (WM_USER + 101)
- //---------------------------------------------------------------------------
- class TFrmNetwork : public TForm
- {
- __published: // IDE-managed Components
- TMemo *reMsg;
- void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
- void __fastcall FormDestroy(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
|