Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:24

0001 // @(#)root/net:$Id$
0002 // Author: Fons Rademakers   18/12/96
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TServerSocket
0013 #define ROOT_TServerSocket
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TServerSocket                                                        //
0019 //                                                                      //
0020 // This class implements server sockets. A server socket waits for      //
0021 // requests to come in over the network. It performs some operation     //
0022 // based on that request and then possibly returns a full duplex socket //
0023 // to the requester. The actual work is done via the TSystem class      //
0024 // (either TUnixSystem or TWinNTSystem).                                //
0025 //                                                                      //
0026 //////////////////////////////////////////////////////////////////////////
0027 
0028 #include "TSocket.h"
0029 #include <string>
0030 
0031 class TSeqCollection;
0032 
0033 typedef Int_t (*SrvAuth_t)(TSocket *sock, const char *, const char *,
0034                            std::string&, Int_t &, Int_t &, std::string &,
0035                            TSeqCollection *);
0036 typedef Int_t (*SrvClup_t)(TSeqCollection *);
0037 
0038 // These mask are globally available to manipulate the option to Accept
0039 const UChar_t kSrvAuth   = 0x1;            // Require client authentication
0040 const UChar_t kSrvNoAuth = (kSrvAuth<<4);  // Force no client authentication
0041 
0042 class TServerSocket : public TSocket {
0043 
0044 private:
0045    TSeqCollection  *fSecContexts; // List of TSecContext with cleanup info
0046    static SrvAuth_t fgSrvAuthHook;
0047    static SrvClup_t fgSrvAuthClupHook;
0048    static UChar_t fgAcceptOpt;     // Default accept options
0049 
0050    TServerSocket() : fSecContexts(nullptr) {}
0051    TServerSocket(const TServerSocket &);
0052    void operator=(const TServerSocket &);
0053    Bool_t Authenticate(TSocket *);
0054 
0055 public:
0056    enum { kDefaultBacklog = 10 };
0057 
0058    TServerSocket(Int_t port, Bool_t reuse = kFALSE, Int_t backlog = kDefaultBacklog,
0059                  Int_t tcpwindowsize = -1);
0060    TServerSocket(const char *service, Bool_t reuse = kFALSE,
0061                  Int_t backlog = kDefaultBacklog, Int_t tcpwindowsize = -1);
0062    virtual ~TServerSocket();
0063 
0064    virtual TSocket      *Accept(UChar_t Opt = 0);
0065    TInetAddress  GetLocalInetAddress() override;
0066    Int_t         GetLocalPort() override;
0067 
0068    Int_t         Send(const TMessage &) override
0069                     { MayNotUse("Send(const TMessage &)"); return 0; }
0070    Int_t         Send(Int_t) override
0071                     { MayNotUse("Send(Int_t)"); return 0; }
0072    Int_t         Send(Int_t, Int_t) override
0073                     { MayNotUse("Send(Int_t, Int_t)"); return 0; }
0074    Int_t         Send(const char *, Int_t = kMESS_STRING) override
0075                     { MayNotUse("Send(const char *, Int_t)"); return 0; }
0076    Int_t         SendObject(const TObject *, Int_t = kMESS_OBJECT) override
0077                     { MayNotUse("SendObject(const TObject *, Int_t)"); return 0; }
0078    Int_t         SendRaw(const void *, Int_t, ESendRecvOptions = kDefault) override
0079                     { MayNotUse("SendRaw(const void *, Int_t, ESendRecvOptions)"); return 0; }
0080    Int_t         Recv(TMessage *&) override
0081                     { MayNotUse("Recv(TMessage *&)"); return 0; }
0082    Int_t         Recv(Int_t &, Int_t &) override
0083                     { MayNotUse("Recv(Int_t &, Int_t &)"); return 0; }
0084    Int_t         Recv(char *, Int_t) override
0085                     { MayNotUse("Recv(char *, Int_t)"); return 0; }
0086    Int_t         Recv(char *, Int_t, Int_t &) override
0087                     { MayNotUse("Recv(char *, Int_t, Int_t &)"); return 0; }
0088    Int_t         RecvRaw(void *, Int_t, ESendRecvOptions = kDefault) override
0089                     { MayNotUse("RecvRaw(void *, Int_t, ESendRecvOptions)"); return 0; }
0090 
0091    static UChar_t     GetAcceptOptions();
0092    static void        SetAcceptOptions(UChar_t Opt);
0093    static void        ShowAcceptOptions();
0094 
0095    ClassDefOverride(TServerSocket, 0);  //This class implements server sockets
0096 };
0097 
0098 #endif