home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Internet 2000 May / MICD_2000_05.iso / CBuilder5 / INSTALL / DATA1.CAB / Program_Built_Files / Include / Vcl / scktcomp.hpp < prev    next >
C/C++ Source or Header  |  2000-02-01  |  25KB  |  660 lines

  1. // Borland C++ Builder
  2. // Copyright (c) 1995, 1999 by Borland International
  3. // All rights reserved
  4.  
  5. // (DO NOT EDIT: machine generated header) 'ScktComp.pas' rev: 5.00
  6.  
  7. #ifndef ScktCompHPP
  8. #define ScktCompHPP
  9.  
  10. #pragma delphiheader begin
  11. #pragma option push -w-
  12. #pragma option push -Vx
  13. #include <SyncObjs.hpp>    // Pascal unit
  14. #include <WinSock.hpp>    // Pascal unit
  15. #include <Classes.hpp>    // Pascal unit
  16. #include <Messages.hpp>    // Pascal unit
  17. #include <Windows.hpp>    // Pascal unit
  18. #include <SysUtils.hpp>    // Pascal unit
  19. #include <SysInit.hpp>    // Pascal unit
  20. #include <System.hpp>    // Pascal unit
  21.  
  22. //-- user supplied -----------------------------------------------------------
  23.  
  24. namespace Scktcomp
  25. {
  26. //-- type declarations -------------------------------------------------------
  27. class DELPHICLASS ESocketError;
  28. class PASCALIMPLEMENTATION ESocketError : public Sysutils::Exception 
  29. {
  30.     typedef Sysutils::Exception inherited;
  31.     
  32. public:
  33.     #pragma option push -w-inl
  34.     /* Exception.Create */ inline __fastcall ESocketError(const AnsiString Msg) : Sysutils::Exception(Msg
  35.         ) { }
  36.     #pragma option pop
  37.     #pragma option push -w-inl
  38.     /* Exception.CreateFmt */ inline __fastcall ESocketError(const AnsiString Msg, const System::TVarRec 
  39.         * Args, const int Args_Size) : Sysutils::Exception(Msg, Args, Args_Size) { }
  40.     #pragma option pop
  41.     #pragma option push -w-inl
  42.     /* Exception.CreateRes */ inline __fastcall ESocketError(int Ident)/* overload */ : Sysutils::Exception(
  43.         Ident) { }
  44.     #pragma option pop
  45.     #pragma option push -w-inl
  46.     /* Exception.CreateResFmt */ inline __fastcall ESocketError(int Ident, const System::TVarRec * Args
  47.         , const int Args_Size)/* overload */ : Sysutils::Exception(Ident, Args, Args_Size) { }
  48.     #pragma option pop
  49.     #pragma option push -w-inl
  50.     /* Exception.CreateHelp */ inline __fastcall ESocketError(const AnsiString Msg, int AHelpContext) : 
  51.         Sysutils::Exception(Msg, AHelpContext) { }
  52.     #pragma option pop
  53.     #pragma option push -w-inl
  54.     /* Exception.CreateFmtHelp */ inline __fastcall ESocketError(const AnsiString Msg, const System::TVarRec 
  55.         * Args, const int Args_Size, int AHelpContext) : Sysutils::Exception(Msg, Args, Args_Size, AHelpContext
  56.         ) { }
  57.     #pragma option pop
  58.     #pragma option push -w-inl
  59.     /* Exception.CreateResHelp */ inline __fastcall ESocketError(int Ident, int AHelpContext)/* overload */
  60.          : Sysutils::Exception(Ident, AHelpContext) { }
  61.     #pragma option pop
  62.     #pragma option push -w-inl
  63.     /* Exception.CreateResFmtHelp */ inline __fastcall ESocketError(System::PResStringRec ResStringRec, 
  64.         const System::TVarRec * Args, const int Args_Size, int AHelpContext)/* overload */ : Sysutils::Exception(
  65.         ResStringRec, Args, Args_Size, AHelpContext) { }
  66.     #pragma option pop
  67.     
  68. public:
  69.     #pragma option push -w-inl
  70.     /* TObject.Destroy */ inline __fastcall virtual ~ESocketError(void) { }
  71.     #pragma option pop
  72.     
  73. };
  74.  
  75.  
  76. struct TCMSocketMessage
  77. {
  78.     unsigned Msg;
  79.     int Socket;
  80.     Word SelectEvent;
  81.     Word SelectError;
  82.     int Result;
  83. } ;
  84.  
  85. struct TCMLookupComplete
  86. {
  87.     unsigned Msg;
  88.     unsigned LookupHandle;
  89.     Word AsyncBufLen;
  90.     Word AsyncError;
  91.     int Result;
  92. } ;
  93.  
  94. #pragma option push -b-
  95. enum TServerType { stNonBlocking, stThreadBlocking };
  96. #pragma option pop
  97.  
  98. #pragma option push -b-
  99. enum TClientType { ctNonBlocking, ctBlocking };
  100. #pragma option pop
  101.  
  102. #pragma option push -b-
  103. enum TAsyncStyle { asRead, asWrite, asOOB, asAccept, asConnect, asClose };
  104. #pragma option pop
  105.  
  106. typedef Set<TAsyncStyle, asRead, asClose>  TAsyncStyles;
  107.  
  108. #pragma option push -b-
  109. enum TSocketEvent { seLookup, seConnecting, seConnect, seDisconnect, seListen, seAccept, seWrite, seRead 
  110.     };
  111. #pragma option pop
  112.  
  113. #pragma option push -b-
  114. enum TLookupState { lsIdle, lsLookupAddress, lsLookupService };
  115. #pragma option pop
  116.  
  117. #pragma option push -b-
  118. enum TErrorEvent { eeGeneral, eeSend, eeReceive, eeConnect, eeDisconnect, eeAccept };
  119. #pragma option pop
  120.  
  121. class DELPHICLASS TCustomWinSocket;
  122. typedef void __fastcall (__closure *TSocketEventEvent)(System::TObject* Sender, TCustomWinSocket* Socket
  123.     , TSocketEvent SocketEvent);
  124.  
  125. typedef void __fastcall (__closure *TSocketErrorEvent)(System::TObject* Sender, TCustomWinSocket* Socket
  126.     , TErrorEvent ErrorEvent, int &ErrorCode);
  127.  
  128. class DELPHICLASS TServerClientWinSocket;
  129. typedef void __fastcall (__closure *TGetSocketEvent)(System::TObject* Sender, int Socket, TServerClientWinSocket* 
  130.     &ClientSocket);
  131.  
  132. class DELPHICLASS TServerClientThread;
  133. typedef void __fastcall (__closure *TGetThreadEvent)(System::TObject* Sender, TServerClientWinSocket* 
  134.     ClientSocket, TServerClientThread* &SocketThread);
  135.  
  136. typedef void __fastcall (__closure *TSocketNotifyEvent)(System::TObject* Sender, TCustomWinSocket* Socket
  137.     );
  138.  
  139. class PASCALIMPLEMENTATION TCustomWinSocket : public System::TObject 
  140. {
  141.     typedef System::TObject inherited;
  142.     
  143. private:
  144.     int FSocket;
  145.     bool FConnected;
  146.     Classes::TStream* FSendStream;
  147.     bool FDropAfterSend;
  148.     HWND FHandle;
  149.     sockaddr_in FAddr;
  150.     TAsyncStyles FAsyncStyles;
  151.     TLookupState FLookupState;
  152.     unsigned FLookupHandle;
  153.     TSocketEventEvent FOnSocketEvent;
  154.     TSocketErrorEvent FOnErrorEvent;
  155.     Syncobjs::TCriticalSection* FSocketLock;
  156.     void *FGetHostData;
  157.     void *FData;
  158.     AnsiString FService;
  159.     Word FPort;
  160.     bool FClient;
  161.     int FQueueSize;
  162.     bool __fastcall SendStreamPiece(void);
  163.     void __fastcall WndProc(Messages::TMessage &Message);
  164.     MESSAGE void __fastcall CMLookupComplete(TCMLookupComplete &Message);
  165.     MESSAGE void __fastcall CMSocketMessage(TCMSocketMessage &Message);
  166.     MESSAGE void __fastcall CMDeferFree(void *Message);
  167.     void __fastcall DeferFree(void);
  168.     void __fastcall DoSetAsyncStyles(void);
  169.     HWND __fastcall GetHandle(void);
  170.     AnsiString __fastcall GetLocalHost();
  171.     AnsiString __fastcall GetLocalAddress();
  172.     int __fastcall GetLocalPort(void);
  173.     AnsiString __fastcall GetRemoteHost();
  174.     AnsiString __fastcall GetRemoteAddress();
  175.     int __fastcall GetRemotePort(void);
  176.     sockaddr_in __fastcall GetRemoteAddr();
  177.     
  178. protected:
  179.     void __fastcall AsyncInitSocket(const AnsiString Name, const AnsiString Address, const AnsiString Service
  180.         , Word Port, int QueueSize, bool Client);
  181.     void __fastcall DoOpen(void);
  182.     void __fastcall DoListen(int QueueSize);
  183.     sockaddr_in __fastcall InitSocket(const AnsiString Name, const AnsiString Address, const AnsiString 
  184.         Service, Word Port, bool Client);
  185.     DYNAMIC void __fastcall Event(TCustomWinSocket* Socket, TSocketEvent SocketEvent);
  186.     DYNAMIC void __fastcall Error(TCustomWinSocket* Socket, TErrorEvent ErrorEvent, int &ErrorCode);
  187.     void __fastcall SetAsyncStyles(TAsyncStyles Value);
  188.     
  189. public:
  190.     __fastcall TCustomWinSocket(int ASocket);
  191.     __fastcall virtual ~TCustomWinSocket(void);
  192.     void __fastcall Close(void);
  193.     virtual void __fastcall DefaultHandler(void *Message);
  194.     void __fastcall Lock(void);
  195.     void __fastcall Unlock(void);
  196.     void __fastcall Listen(const AnsiString Name, const AnsiString Address, const AnsiString Service, Word 
  197.         Port, int QueueSize, bool Block);
  198.     void __fastcall Open(const AnsiString Name, const AnsiString Address, const AnsiString Service, Word 
  199.         Port, bool Block);
  200.     virtual void __fastcall Accept(int Socket);
  201.     virtual void __fastcall Connect(int Socket);
  202.     virtual void __fastcall Disconnect(int Socket);
  203.     virtual void __fastcall Read(int Socket);
  204.     virtual void __fastcall Write(int Socket);
  205.     in_addr __fastcall LookupName(const AnsiString name);
  206.     int __fastcall LookupService(const AnsiString service);
  207.     int __fastcall ReceiveLength(void);
  208.     int __fastcall ReceiveBuf(void *Buf, int Count);
  209.     AnsiString __fastcall ReceiveText();
  210.     int __fastcall SendBuf(void *Buf, int Count);
  211.     bool __fastcall SendStream(Classes::TStream* AStream);
  212.     bool __fastcall SendStreamThenDrop(Classes::TStream* AStream);
  213.     int __fastcall SendText(const AnsiString S);
  214.     __property AnsiString LocalHost = {read=GetLocalHost};
  215.     __property AnsiString LocalAddress = {read=GetLocalAddress};
  216.     __property int LocalPort = {read=GetLocalPort, nodefault};
  217.     __property AnsiString RemoteHost = {read=GetRemoteHost};
  218.     __property AnsiString RemoteAddress = {read=GetRemoteAddress};
  219.     __property int RemotePort = {read=GetRemotePort, nodefault};
  220.     __property sockaddr_in RemoteAddr = {read=GetRemoteAddr};
  221.     __property bool Connected = {read=FConnected, nodefault};
  222.     __property sockaddr_in Addr = {read=FAddr};
  223.     __property TAsyncStyles ASyncStyles = {read=FAsyncStyles, write=SetAsyncStyles, nodefault};
  224.     __property HWND Handle = {read=GetHandle, nodefault};
  225.     __property int SocketHandle = {read=FSocket, nodefault};
  226.     __property TLookupState LookupState = {read=FLookupState, nodefault};
  227.     __property TSocketEventEvent OnSocketEvent = {read=FOnSocketEvent, write=FOnSocketEvent};
  228.     __property TSocketErrorEvent OnErrorEvent = {read=FOnErrorEvent, write=FOnErrorEvent};
  229.     __property void * Data = {read=FData, write=FData};
  230. };
  231.  
  232.  
  233. class DELPHICLASS TClientWinSocket;
  234. class PASCALIMPLEMENTATION TClientWinSocket : public TCustomWinSocket 
  235. {
  236.     typedef TCustomWinSocket inherited;
  237.     
  238. private:
  239.     TClientType FClientType;
  240.     
  241. protected:
  242.     void __fastcall SetClientType(TClientType Value);
  243.     
  244. public:
  245.     virtual void __fastcall Connect(int Socket);
  246.     __property TClientType ClientType = {read=FClientType, write=SetClientType, nodefault};
  247. public:
  248.     #pragma option push -w-inl
  249.     /* TCustomWinSocket.Create */ inline __fastcall TClientWinSocket(int ASocket) : TCustomWinSocket(ASocket
  250.         ) { }
  251.     #pragma option pop
  252.     #pragma option push -w-inl
  253.     /* TCustomWinSocket.Destroy */ inline __fastcall virtual ~TClientWinSocket(void) { }
  254.     #pragma option pop
  255.     
  256. };
  257.  
  258.  
  259. class DELPHICLASS TServerWinSocket;
  260. class DELPHICLASS TServerAcceptThread;
  261. class PASCALIMPLEMENTATION TServerAcceptThread : public Classes::TThread 
  262. {
  263.     typedef Classes::TThread inherited;
  264.     
  265. private:
  266.     TServerWinSocket* FServerSocket;
  267.     
  268. public:
  269.     __fastcall TServerAcceptThread(bool CreateSuspended, TServerWinSocket* ASocket);
  270.     virtual void __fastcall Execute(void);
  271.     __property TServerWinSocket* ServerSocket = {read=FServerSocket};
  272. public:
  273.     #pragma option push -w-inl
  274.     /* TThread.Destroy */ inline __fastcall virtual ~TServerAcceptThread(void) { }
  275.     #pragma option pop
  276.     
  277. };
  278.  
  279.  
  280. typedef void __fastcall (__closure *TThreadNotifyEvent)(System::TObject* Sender, TServerClientThread* 
  281.     Thread);
  282.  
  283. class PASCALIMPLEMENTATION TServerWinSocket : public TCustomWinSocket 
  284. {
  285.     typedef TCustomWinSocket inherited;
  286.     
  287. private:
  288.     TServerType FServerType;
  289.     int FThreadCacheSize;
  290.     Classes::TList* FConnections;
  291.     Classes::TList* FActiveThreads;
  292.     Syncobjs::TCriticalSection* FListLock;
  293.     TServerAcceptThread* FServerAcceptThread;
  294.     TGetSocketEvent FOnGetSocket;
  295.     TGetThreadEvent FOnGetThread;
  296.     TThreadNotifyEvent FOnThreadStart;
  297.     TThreadNotifyEvent FOnThreadEnd;
  298.     TSocketNotifyEvent FOnClientConnect;
  299.     TSocketNotifyEvent FOnClientDisconnect;
  300.     TSocketNotifyEvent FOnClientRead;
  301.     TSocketNotifyEvent FOnClientWrite;
  302.     TSocketErrorEvent FOnClientError;
  303.     void __fastcall AddClient(TServerClientWinSocket* AClient);
  304.     void __fastcall RemoveClient(TServerClientWinSocket* AClient);
  305.     void __fastcall AddThread(TServerClientThread* AThread);
  306.     void __fastcall RemoveThread(TServerClientThread* AThread);
  307.     void __fastcall ClientEvent(System::TObject* Sender, TCustomWinSocket* Socket, TSocketEvent SocketEvent
  308.         );
  309.     void __fastcall ClientError(System::TObject* Sender, TCustomWinSocket* Socket, TErrorEvent ErrorEvent
  310.         , int &ErrorCode);
  311.     int __fastcall GetActiveConnections(void);
  312.     int __fastcall GetActiveThreads(void);
  313.     TCustomWinSocket* __fastcall GetConnections(int Index);
  314.     int __fastcall GetIdleThreads(void);
  315.     
  316. protected:
  317.     virtual TServerClientThread* __fastcall DoCreateThread(TServerClientWinSocket* ClientSocket);
  318.     HIDESBASE void __fastcall Listen(AnsiString &Name, AnsiString &Address, AnsiString &Service, Word Port
  319.         , int QueueSize);
  320.     void __fastcall SetServerType(TServerType Value);
  321.     void __fastcall SetThreadCacheSize(int Value);
  322.     DYNAMIC void __fastcall ThreadEnd(TServerClientThread* AThread);
  323.     DYNAMIC void __fastcall ThreadStart(TServerClientThread* AThread);
  324.     DYNAMIC TServerClientWinSocket* __fastcall GetClientSocket(int Socket);
  325.     DYNAMIC TServerClientThread* __fastcall GetServerThread(TServerClientWinSocket* ClientSocket);
  326.     DYNAMIC void __fastcall ClientRead(TCustomWinSocket* Socket);
  327.     DYNAMIC void __fastcall ClientWrite(TCustomWinSocket* Socket);
  328.     DYNAMIC void __fastcall ClientConnect(TCustomWinSocket* Socket);
  329.     DYNAMIC void __fastcall ClientDisconnect(TCustomWinSocket* Socket);
  330.     DYNAMIC void __fastcall ClientErrorEvent(TCustomWinSocket* Socket, TErrorEvent ErrorEvent, int &ErrorCode
  331.         );
  332.     
  333. public:
  334.     __fastcall TServerWinSocket(int ASocket);
  335.     __fastcall virtual ~TServerWinSocket(void);
  336.     virtual void __fastcall Accept(int Socket);
  337.     virtual void __fastcall Disconnect(int Socket);
  338.     TServerClientThread* __fastcall GetClientThread(TServerClientWinSocket* ClientSocket);
  339.     __property int ActiveConnections = {read=GetActiveConnections, nodefault};
  340.     __property int ActiveThreads = {read=GetActiveThreads, nodefault};
  341.     __property TCustomWinSocket* Connections[int Index] = {read=GetConnections};
  342.     __property int IdleThreads = {read=GetIdleThreads, nodefault};
  343.     __property TServerType ServerType = {read=FServerType, write=SetServerType, nodefault};
  344.     __property int ThreadCacheSize = {read=FThreadCacheSize, write=SetThreadCacheSize, nodefault};
  345.     __property TGetSocketEvent OnGetSocket = {read=FOnGetSocket, write=FOnGetSocket};
  346.     __property TGetThreadEvent OnGetThread = {read=FOnGetThread, write=FOnGetThread};
  347.     __property TThreadNotifyEvent OnThreadStart = {read=FOnThreadStart, write=FOnThreadStart};
  348.     __property TThreadNotifyEvent OnThreadEnd = {read=FOnThreadEnd, write=FOnThreadEnd};
  349.     __property TSocketNotifyEvent OnClientConnect = {read=FOnClientConnect, write=FOnClientConnect};
  350.     __property TSocketNotifyEvent OnClientDisconnect = {read=FOnClientDisconnect, write=FOnClientDisconnect
  351.         };
  352.     __property TSocketNotifyEvent OnClientRead = {read=FOnClientRead, write=FOnClientRead};
  353.     __property TSocketNotifyEvent OnClientWrite = {read=FOnClientWrite, write=FOnClientWrite};
  354.     __property TSocketErrorEvent OnClientError = {read=FOnClientError, write=FOnClientError};
  355. };
  356.  
  357.  
  358. class PASCALIMPLEMENTATION TServerClientWinSocket : public TCustomWinSocket 
  359. {
  360.     typedef TCustomWinSocket inherited;
  361.     
  362. private:
  363.     TServerWinSocket* FServerWinSocket;
  364.     
  365. public:
  366.     __fastcall TServerClientWinSocket(int Socket, TServerWinSocket* ServerWinSocket);
  367.     __fastcall virtual ~TServerClientWinSocket(void);
  368.     __property TServerWinSocket* ServerWinSocket = {read=FServerWinSocket};
  369. };
  370.  
  371.  
  372. class PASCALIMPLEMENTATION TServerClientThread : public Classes::TThread 
  373. {
  374.     typedef Classes::TThread inherited;
  375.     
  376. private:
  377.     TServerClientWinSocket* FClientSocket;
  378.     TServerWinSocket* FServerSocket;
  379.     Sysutils::Exception* FException;
  380.     Syncobjs::TSimpleEvent* FEvent;
  381.     bool FKeepInCache;
  382.     void *FData;
  383.     void __fastcall HandleEvent(System::TObject* Sender, TCustomWinSocket* Socket, TSocketEvent SocketEvent
  384.         );
  385.     void __fastcall HandleError(System::TObject* Sender, TCustomWinSocket* Socket, TErrorEvent ErrorEvent
  386.         , int &ErrorCode);
  387.     void __fastcall DoHandleException(void);
  388.     void __fastcall DoRead(void);
  389.     void __fastcall DoWrite(void);
  390.     
  391. protected:
  392.     virtual void __fastcall DoTerminate(void);
  393.     virtual void __fastcall Execute(void);
  394.     virtual void __fastcall ClientExecute(void);
  395.     virtual void __fastcall Event(TSocketEvent SocketEvent);
  396.     virtual void __fastcall Error(TErrorEvent ErrorEvent, int &ErrorCode);
  397.     virtual void __fastcall HandleException(void);
  398.     void __fastcall ReActivate(TServerClientWinSocket* ASocket);
  399.     bool __fastcall StartConnect(void);
  400.     bool __fastcall EndConnect(void);
  401.     
  402. public:
  403.     __fastcall TServerClientThread(bool CreateSuspended, TServerClientWinSocket* ASocket);
  404.     __fastcall virtual ~TServerClientThread(void);
  405.     __property TServerClientWinSocket* ClientSocket = {read=FClientSocket};
  406.     __property TServerWinSocket* ServerSocket = {read=FServerSocket};
  407.     __property bool KeepInCache = {read=FKeepInCache, write=FKeepInCache, nodefault};
  408.     __property void * Data = {read=FData, write=FData};
  409. };
  410.  
  411.  
  412. class DELPHICLASS TAbstractSocket;
  413. class PASCALIMPLEMENTATION TAbstractSocket : public Classes::TComponent 
  414. {
  415.     typedef Classes::TComponent inherited;
  416.     
  417. private:
  418.     bool FActive;
  419.     int FPort;
  420.     AnsiString FAddress;
  421.     AnsiString FHost;
  422.     AnsiString FService;
  423.     void __fastcall DoEvent(System::TObject* Sender, TCustomWinSocket* Socket, TSocketEvent SocketEvent
  424.         );
  425.     void __fastcall DoError(System::TObject* Sender, TCustomWinSocket* Socket, TErrorEvent ErrorEvent, 
  426.         int &ErrorCode);
  427.     
  428. protected:
  429.     virtual void __fastcall Event(TCustomWinSocket* Socket, TSocketEvent SocketEvent) = 0 ;
  430.     virtual void __fastcall Error(TCustomWinSocket* Socket, TErrorEvent ErrorEvent, int &ErrorCode) = 0 
  431.         ;
  432.     virtual void __fastcall DoActivate(bool Value) = 0 ;
  433.     void __fastcall InitSocket(TCustomWinSocket* Socket);
  434.     virtual void __fastcall Loaded(void);
  435.     void __fastcall SetActive(bool Value);
  436.     void __fastcall SetAddress(AnsiString Value);
  437.     void __fastcall SetHost(AnsiString Value);
  438.     void __fastcall SetPort(int Value);
  439.     void __fastcall SetService(AnsiString Value);
  440.     __property bool Active = {read=FActive, write=SetActive, nodefault};
  441.     __property AnsiString Address = {read=FAddress, write=SetAddress};
  442.     __property AnsiString Host = {read=FHost, write=SetHost};
  443.     __property int Port = {read=FPort, write=SetPort, nodefault};
  444.     __property AnsiString Service = {read=FService, write=SetService};
  445.     
  446. public:
  447.     void __fastcall Open(void);
  448.     void __fastcall Close(void);
  449. public:
  450.     #pragma option push -w-inl
  451.     /* TComponent.Create */ inline __fastcall virtual TAbstractSocket(Classes::TComponent* AOwner) : Classes::TComponent(
  452.         AOwner) { }
  453.     #pragma option pop
  454.     #pragma option push -w-inl
  455.     /* TComponent.Destroy */ inline __fastcall virtual ~TAbstractSocket(void) { }
  456.     #pragma option pop
  457.     
  458. };
  459.  
  460.  
  461. class DELPHICLASS TCustomSocket;
  462. class PASCALIMPLEMENTATION TCustomSocket : public TAbstractSocket 
  463. {
  464.     typedef TAbstractSocket inherited;
  465.     
  466. private:
  467.     TSocketNotifyEvent FOnLookup;
  468.     TSocketNotifyEvent FOnConnect;
  469.     TSocketNotifyEvent FOnConnecting;
  470.     TSocketNotifyEvent FOnDisconnect;
  471.     TSocketNotifyEvent FOnListen;
  472.     TSocketNotifyEvent FOnAccept;
  473.     TSocketNotifyEvent FOnRead;
  474.     TSocketNotifyEvent FOnWrite;
  475.     TSocketErrorEvent FOnError;
  476.     
  477. protected:
  478.     virtual void __fastcall Event(TCustomWinSocket* Socket, TSocketEvent SocketEvent);
  479.     virtual void __fastcall Error(TCustomWinSocket* Socket, TErrorEvent ErrorEvent, int &ErrorCode);
  480.     __property TSocketNotifyEvent OnLookup = {read=FOnLookup, write=FOnLookup};
  481.     __property TSocketNotifyEvent OnConnecting = {read=FOnConnecting, write=FOnConnecting};
  482.     __property TSocketNotifyEvent OnConnect = {read=FOnConnect, write=FOnConnect};
  483.     __property TSocketNotifyEvent OnDisconnect = {read=FOnDisconnect, write=FOnDisconnect};
  484.     __property TSocketNotifyEvent OnListen = {read=FOnListen, write=FOnListen};
  485.     __property TSocketNotifyEvent OnAccept = {read=FOnAccept, write=FOnAccept};
  486.     __property TSocketNotifyEvent OnRead = {read=FOnRead, write=FOnRead};
  487.     __property TSocketNotifyEvent OnWrite = {read=FOnWrite, write=FOnWrite};
  488.     __property TSocketErrorEvent OnError = {read=FOnError, write=FOnError};
  489. public:
  490.     #pragma option push -w-inl
  491.     /* TComponent.Create */ inline __fastcall virtual TCustomSocket(Classes::TComponent* AOwner) : TAbstractSocket(
  492.         AOwner) { }
  493.     #pragma option pop
  494.     #pragma option push -w-inl
  495.     /* TComponent.Destroy */ inline __fastcall virtual ~TCustomSocket(void) { }
  496.     #pragma option pop
  497.     
  498. };
  499.  
  500.  
  501. class DELPHICLASS TWinSocketStream;
  502. class PASCALIMPLEMENTATION TWinSocketStream : public Classes::TStream 
  503. {
  504.     typedef Classes::TStream inherited;
  505.     
  506. private:
  507.     TCustomWinSocket* FSocket;
  508.     int FTimeout;
  509.     Syncobjs::TSimpleEvent* FEvent;
  510.     
  511. public:
  512.     __fastcall TWinSocketStream(TCustomWinSocket* ASocket, int TimeOut);
  513.     __fastcall virtual ~TWinSocketStream(void);
  514.     bool __fastcall WaitForData(int Timeout);
  515.     virtual int __fastcall Read(void *Buffer, int Count);
  516.     virtual int __fastcall Write(const void *Buffer, int Count);
  517.     virtual int __fastcall Seek(int Offset, Word Origin);
  518.     __property int TimeOut = {read=FTimeout, write=FTimeout, nodefault};
  519. };
  520.  
  521.  
  522. class DELPHICLASS TClientSocket;
  523. class PASCALIMPLEMENTATION TClientSocket : public TCustomSocket 
  524. {
  525.     typedef TCustomSocket inherited;
  526.     
  527. private:
  528.     TClientWinSocket* FClientSocket;
  529.     
  530. protected:
  531.     virtual void __fastcall DoActivate(bool Value);
  532.     TClientType __fastcall GetClientType(void);
  533.     void __fastcall SetClientType(TClientType Value);
  534.     
  535. public:
  536.     __fastcall virtual TClientSocket(Classes::TComponent* AOwner);
  537.     __fastcall virtual ~TClientSocket(void);
  538.     __property TClientWinSocket* Socket = {read=FClientSocket};
  539.     
  540. __published:
  541.     __property Active ;
  542.     __property Address ;
  543.     __property TClientType ClientType = {read=GetClientType, write=SetClientType, nodefault};
  544.     __property Host ;
  545.     __property Port ;
  546.     __property Service ;
  547.     __property OnLookup ;
  548.     __property OnConnecting ;
  549.     __property OnConnect ;
  550.     __property OnDisconnect ;
  551.     __property OnRead ;
  552.     __property OnWrite ;
  553.     __property OnError ;
  554. };
  555.  
  556.  
  557. class DELPHICLASS TCustomServerSocket;
  558. class PASCALIMPLEMENTATION TCustomServerSocket : public TCustomSocket 
  559. {
  560.     typedef TCustomSocket inherited;
  561.     
  562. protected:
  563.     TServerWinSocket* FServerSocket;
  564.     virtual void __fastcall DoActivate(bool Value);
  565.     TServerType __fastcall GetServerType(void);
  566.     TGetThreadEvent __fastcall GetGetThreadEvent();
  567.     TGetSocketEvent __fastcall GetGetSocketEvent();
  568.     int __fastcall GetThreadCacheSize(void);
  569.     TThreadNotifyEvent __fastcall GetOnThreadStart();
  570.     TThreadNotifyEvent __fastcall GetOnThreadEnd();
  571.     TSocketNotifyEvent __fastcall GetOnClientEvent(int Index);
  572.     TSocketErrorEvent __fastcall GetOnClientError();
  573.     void __fastcall SetServerType(TServerType Value);
  574.     void __fastcall SetGetThreadEvent(TGetThreadEvent Value);
  575.     void __fastcall SetGetSocketEvent(TGetSocketEvent Value);
  576.     void __fastcall SetThreadCacheSize(int Value);
  577.     void __fastcall SetOnThreadStart(TThreadNotifyEvent Value);
  578.     void __fastcall SetOnThreadEnd(TThreadNotifyEvent Value);
  579.     void __fastcall SetOnClientEvent(int Index, TSocketNotifyEvent Value);
  580.     void __fastcall SetOnClientError(TSocketErrorEvent Value);
  581.     __property TServerType ServerType = {read=GetServerType, write=SetServerType, nodefault};
  582.     __property int ThreadCacheSize = {read=GetThreadCacheSize, write=SetThreadCacheSize, nodefault};
  583.     __property TGetThreadEvent OnGetThread = {read=GetGetThreadEvent, write=SetGetThreadEvent};
  584.     __property TGetSocketEvent OnGetSocket = {read=GetGetSocketEvent, write=SetGetSocketEvent};
  585.     __property TThreadNotifyEvent OnThreadStart = {read=GetOnThreadStart, write=SetOnThreadStart};
  586.     __property TThreadNotifyEvent OnThreadEnd = {read=GetOnThreadEnd, write=SetOnThreadEnd};
  587.     __property TSocketNotifyEvent OnClientConnect = {read=GetOnClientEvent, write=SetOnClientEvent, index=2
  588.         };
  589.     __property TSocketNotifyEvent OnClientDisconnect = {read=GetOnClientEvent, write=SetOnClientEvent, 
  590.         index=3};
  591.     __property TSocketNotifyEvent OnClientRead = {read=GetOnClientEvent, write=SetOnClientEvent, index=0
  592.         };
  593.     __property TSocketNotifyEvent OnClientWrite = {read=GetOnClientEvent, write=SetOnClientEvent, index=1
  594.         };
  595.     __property TSocketErrorEvent OnClientError = {read=GetOnClientError, write=SetOnClientError};
  596.     
  597. public:
  598.     __fastcall virtual ~TCustomServerSocket(void);
  599. public:
  600.     #pragma option push -w-inl
  601.     /* TComponent.Create */ inline __fastcall virtual TCustomServerSocket(Classes::TComponent* AOwner) : 
  602.         TCustomSocket(AOwner) { }
  603.     #pragma option pop
  604.     
  605. };
  606.  
  607.  
  608. class DELPHICLASS TServerSocket;
  609. class PASCALIMPLEMENTATION TServerSocket : public TCustomServerSocket 
  610. {
  611.     typedef TCustomServerSocket inherited;
  612.     
  613. public:
  614.     __fastcall virtual TServerSocket(Classes::TComponent* AOwner);
  615.     __property TServerWinSocket* Socket = {read=FServerSocket};
  616.     
  617. __published:
  618.     __property Active ;
  619.     __property Port ;
  620.     __property Service ;
  621.     __property ServerType ;
  622.     __property ThreadCacheSize ;
  623.     __property OnListen ;
  624.     __property OnAccept ;
  625.     __property OnGetThread ;
  626.     __property OnGetSocket ;
  627.     __property OnThreadStart ;
  628.     __property OnThreadEnd ;
  629.     __property OnClientConnect ;
  630.     __property OnClientDisconnect ;
  631.     __property OnClientRead ;
  632.     __property OnClientWrite ;
  633.     __property OnClientError ;
  634. public:
  635.     #pragma option push -w-inl
  636.     /* TCustomServerSocket.Destroy */ inline __fastcall virtual ~TServerSocket(void) { }
  637.     #pragma option pop
  638.     
  639. };
  640.  
  641.  
  642. typedef void __fastcall (*TSocketErrorProc)(int ErrorCode);
  643.  
  644. //-- var, const, procedure ---------------------------------------------------
  645. static const Word CM_SOCKETMESSAGE = 0x401;
  646. static const Word CM_DEFERFREE = 0x402;
  647. static const Word CM_LOOKUPCOMPLETE = 0x403;
  648. extern PACKAGE TSocketErrorProc __fastcall SetErrorProc(TSocketErrorProc ErrorProc);
  649.  
  650. }    /* namespace Scktcomp */
  651. #if !defined(NO_IMPLICIT_NAMESPACE_USE)
  652. using namespace Scktcomp;
  653. #endif
  654. #pragma option pop    // -w-
  655. #pragma option pop    // -Vx
  656.  
  657. #pragma delphiheader end.
  658. //-- end unit ----------------------------------------------------------------
  659. #endif    // ScktComp
  660.