// @(#)root/net:$Id$
// Author: Fons Rademakers   18/12/96

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TServerSocket
#define ROOT_TServerSocket


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TServerSocket                                                        //
//                                                                      //
// This class implements server sockets. A server socket waits for      //
// requests to come in over the network. It performs some operation     //
// based on that request and then possibly returns a full duplex socket //
// to the requester. The actual work is done via the TSystem class      //
// (either TUnixSystem or TWinNTSystem).                                //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TSocket
#include "TSocket.h"
#endif
#include <string>

class TSeqCollection;

typedef Int_t (*SrvAuth_t)(TSocket *sock, const char *, const char *,
                           std::string&, Int_t &, Int_t &, std::string &,
                           TSeqCollection *);
typedef Int_t (*SrvClup_t)(TSeqCollection *);

// These mask are globally available to manipulate the option to Accept
const UChar_t kSrvAuth   = 0x1;            // Require client authentication
const UChar_t kSrvNoAuth = (kSrvAuth<<4);  // Force no client authentication

class TServerSocket : public TSocket {

private:
   TSeqCollection  *fSecContexts; // List of TSecContext with cleanup info
   static SrvAuth_t fgSrvAuthHook;
   static SrvClup_t fgSrvAuthClupHook;
   static UChar_t fgAcceptOpt;     // Default accept options

   TServerSocket() : fSecContexts(0) { }
   TServerSocket(const TServerSocket &);
   void operator=(const TServerSocket &);
   Bool_t Authenticate(TSocket *);

public:
   enum { kDefaultBacklog = 10 };

   TServerSocket(Int_t port, Bool_t reuse = kFALSE, Int_t backlog = kDefaultBacklog,
                 Int_t tcpwindowsize = -1);
   TServerSocket(const char *service, Bool_t reuse = kFALSE,
                 Int_t backlog = kDefaultBacklog, Int_t tcpwindowsize = -1);
   virtual ~TServerSocket();

   virtual TSocket      *Accept(UChar_t Opt = 0);
   virtual TInetAddress  GetLocalInetAddress();
   virtual Int_t         GetLocalPort();

   Int_t         Send(const TMessage &)
                    { MayNotUse("Send(const TMessage &)"); return 0; }
   Int_t         Send(Int_t)
                    { MayNotUse("Send(Int_t)"); return 0; }
   Int_t         Send(Int_t, Int_t)
                    { MayNotUse("Send(Int_t, Int_t)"); return 0; }
   Int_t         Send(const char *, Int_t = kMESS_STRING)
                    { MayNotUse("Send(const char *, Int_t)"); return 0; }
   Int_t         SendObject(const TObject *, Int_t = kMESS_OBJECT)
                    { MayNotUse("SendObject(const TObject *, Int_t)"); return 0; }
   Int_t         SendRaw(const void *, Int_t, ESendRecvOptions = kDefault)
                    { MayNotUse("SendRaw(const void *, Int_t, ESendRecvOptions)"); return 0; }
   Int_t         Recv(TMessage *&)
                    { MayNotUse("Recv(TMessage *&)"); return 0; }
   Int_t         Recv(Int_t &, Int_t &)
                    { MayNotUse("Recv(Int_t &, Int_t &)"); return 0; }
   Int_t         Recv(char *, Int_t)
                    { MayNotUse("Recv(char *, Int_t)"); return 0; }
   Int_t         Recv(char *, Int_t, Int_t &)
                    { MayNotUse("Recv(char *, Int_t, Int_t &)"); return 0; }
   Int_t         RecvRaw(void *, Int_t, ESendRecvOptions = kDefault)
                    { MayNotUse("RecvRaw(void *, Int_t, ESendRecvOptions)"); return 0; }

   static UChar_t     GetAcceptOptions();
   static void        SetAcceptOptions(UChar_t Opt);
   static void        ShowAcceptOptions();

   ClassDef(TServerSocket,1)  //This class implements server sockets
};

#endif
 TServerSocket.h:1
 TServerSocket.h:2
 TServerSocket.h:3
 TServerSocket.h:4
 TServerSocket.h:5
 TServerSocket.h:6
 TServerSocket.h:7
 TServerSocket.h:8
 TServerSocket.h:9
 TServerSocket.h:10
 TServerSocket.h:11
 TServerSocket.h:12
 TServerSocket.h:13
 TServerSocket.h:14
 TServerSocket.h:15
 TServerSocket.h:16
 TServerSocket.h:17
 TServerSocket.h:18
 TServerSocket.h:19
 TServerSocket.h:20
 TServerSocket.h:21
 TServerSocket.h:22
 TServerSocket.h:23
 TServerSocket.h:24
 TServerSocket.h:25
 TServerSocket.h:26
 TServerSocket.h:27
 TServerSocket.h:28
 TServerSocket.h:29
 TServerSocket.h:30
 TServerSocket.h:31
 TServerSocket.h:32
 TServerSocket.h:33
 TServerSocket.h:34
 TServerSocket.h:35
 TServerSocket.h:36
 TServerSocket.h:37
 TServerSocket.h:38
 TServerSocket.h:39
 TServerSocket.h:40
 TServerSocket.h:41
 TServerSocket.h:42
 TServerSocket.h:43
 TServerSocket.h:44
 TServerSocket.h:45
 TServerSocket.h:46
 TServerSocket.h:47
 TServerSocket.h:48
 TServerSocket.h:49
 TServerSocket.h:50
 TServerSocket.h:51
 TServerSocket.h:52
 TServerSocket.h:53
 TServerSocket.h:54
 TServerSocket.h:55
 TServerSocket.h:56
 TServerSocket.h:57
 TServerSocket.h:58
 TServerSocket.h:59
 TServerSocket.h:60
 TServerSocket.h:61
 TServerSocket.h:62
 TServerSocket.h:63
 TServerSocket.h:64
 TServerSocket.h:65
 TServerSocket.h:66
 TServerSocket.h:67
 TServerSocket.h:68
 TServerSocket.h:69
 TServerSocket.h:70
 TServerSocket.h:71
 TServerSocket.h:72
 TServerSocket.h:73
 TServerSocket.h:74
 TServerSocket.h:75
 TServerSocket.h:76
 TServerSocket.h:77
 TServerSocket.h:78
 TServerSocket.h:79
 TServerSocket.h:80
 TServerSocket.h:81
 TServerSocket.h:82
 TServerSocket.h:83
 TServerSocket.h:84
 TServerSocket.h:85
 TServerSocket.h:86
 TServerSocket.h:87
 TServerSocket.h:88
 TServerSocket.h:89
 TServerSocket.h:90
 TServerSocket.h:91
 TServerSocket.h:92
 TServerSocket.h:93
 TServerSocket.h:94
 TServerSocket.h:95
 TServerSocket.h:96
 TServerSocket.h:97
 TServerSocket.h:98
 TServerSocket.h:99
 TServerSocket.h:100