Logo ROOT   6.08/07
Reference Guide
TServerSocket.h
Go to the documentation of this file.
1 // @(#)root/net:$Id$
2 // Author: Fons Rademakers 18/12/96
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TServerSocket
13 #define ROOT_TServerSocket
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TServerSocket //
19 // //
20 // This class implements server sockets. A server socket waits for //
21 // requests to come in over the network. It performs some operation //
22 // based on that request and then possibly returns a full duplex socket //
23 // to the requester. The actual work is done via the TSystem class //
24 // (either TUnixSystem or TWinNTSystem). //
25 // //
26 //////////////////////////////////////////////////////////////////////////
27 
28 #ifndef ROOT_TSocket
29 #include "TSocket.h"
30 #endif
31 #include <string>
32 
33 class TSeqCollection;
34 
35 typedef Int_t (*SrvAuth_t)(TSocket *sock, const char *, const char *,
36  std::string&, Int_t &, Int_t &, std::string &,
37  TSeqCollection *);
39 
40 // These mask are globally available to manipulate the option to Accept
41 const UChar_t kSrvAuth = 0x1; // Require client authentication
42 const UChar_t kSrvNoAuth = (kSrvAuth<<4); // Force no client authentication
43 
44 class TServerSocket : public TSocket {
45 
46 private:
47  TSeqCollection *fSecContexts; // List of TSecContext with cleanup info
50  static UChar_t fgAcceptOpt; // Default accept options
51 
52  TServerSocket() : fSecContexts(0) { }
54  void operator=(const TServerSocket &);
56 
57 public:
58  enum { kDefaultBacklog = 10 };
59 
60  TServerSocket(Int_t port, Bool_t reuse = kFALSE, Int_t backlog = kDefaultBacklog,
61  Int_t tcpwindowsize = -1);
62  TServerSocket(const char *service, Bool_t reuse = kFALSE,
63  Int_t backlog = kDefaultBacklog, Int_t tcpwindowsize = -1);
64  virtual ~TServerSocket();
65 
66  virtual TSocket *Accept(UChar_t Opt = 0);
68  virtual Int_t GetLocalPort();
69 
70  Int_t Send(const TMessage &)
71  { MayNotUse("Send(const TMessage &)"); return 0; }
73  { MayNotUse("Send(Int_t)"); return 0; }
75  { MayNotUse("Send(Int_t, Int_t)"); return 0; }
76  Int_t Send(const char *, Int_t = kMESS_STRING)
77  { MayNotUse("Send(const char *, Int_t)"); return 0; }
79  { MayNotUse("SendObject(const TObject *, Int_t)"); return 0; }
81  { MayNotUse("SendRaw(const void *, Int_t, ESendRecvOptions)"); return 0; }
83  { MayNotUse("Recv(TMessage *&)"); return 0; }
85  { MayNotUse("Recv(Int_t &, Int_t &)"); return 0; }
86  Int_t Recv(char *, Int_t)
87  { MayNotUse("Recv(char *, Int_t)"); return 0; }
88  Int_t Recv(char *, Int_t, Int_t &)
89  { MayNotUse("Recv(char *, Int_t, Int_t &)"); return 0; }
91  { MayNotUse("RecvRaw(void *, Int_t, ESendRecvOptions)"); return 0; }
92 
93  static UChar_t GetAcceptOptions();
94  static void SetAcceptOptions(UChar_t Opt);
95  static void ShowAcceptOptions();
96 
97  ClassDef(TServerSocket, 0); //This class implements server sockets
98 };
99 
100 #endif
virtual ~TServerSocket()
Destructor: cleanup authentication stuff (if any) and close.
Int_t Recv(char *, Int_t)
Receive a character string message of maximum max length.
Definition: TServerSocket.h:86
virtual Int_t GetLocalPort()
Get port # to which server socket is bound. In case of error returns -1.
This class represents an Internet Protocol (IP) address.
Definition: TInetAddress.h:40
Int_t Send(Int_t)
Send a single message opcode.
Definition: TServerSocket.h:72
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t Send(const char *, Int_t=kMESS_STRING)
Send a character string buffer.
Definition: TServerSocket.h:76
static void SetAcceptOptions(UChar_t Opt)
Set default options for Accept according to modifier &#39;mod&#39;.
ESendRecvOptions
Definition: TSocket.h:65
Int_t RecvRaw(void *, Int_t, ESendRecvOptions=kDefault)
Receive a raw buffer of specified length bytes.
Definition: TServerSocket.h:90
Sequenceable collection abstract base class.
#define ClassDef(name, id)
Definition: Rtypes.h:254
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
Definition: TObject.cxx:978
virtual TSocket * Accept(UChar_t Opt=0)
Accept a connection on a server socket.
const UChar_t kSrvAuth
Definition: TServerSocket.h:41
Int_t(* SrvAuth_t)(TSocket *sock, const char *, const char *, std::string &, Int_t &, Int_t &, std::string &, TSeqCollection *)
Definition: TServerSocket.h:35
const UChar_t kSrvNoAuth
Definition: TServerSocket.h:42
TSeqCollection * fSecContexts
Definition: TServerSocket.h:47
static UChar_t fgAcceptOpt
Definition: TServerSocket.h:50
Int_t Recv(Int_t &, Int_t &)
Receives a status and a message type.
Definition: TServerSocket.h:84
Int_t Recv(char *, Int_t, Int_t &)
Receive a character string message of maximum max length.
Definition: TServerSocket.h:88
Int_t Recv(TMessage *&)
Receive a TMessage object.
Definition: TServerSocket.h:82
virtual TInetAddress GetLocalInetAddress()
Return internet address of host to which the server socket is bound, i.e.
Int_t Send(Int_t, Int_t)
Send a status and a single message opcode.
Definition: TServerSocket.h:74
Int_t Send(const TMessage &)
Send a TMessage object.
Definition: TServerSocket.h:70
Int_t SendRaw(const void *, Int_t, ESendRecvOptions=kDefault)
Send a raw buffer of specified length.
Definition: TServerSocket.h:80
Int_t(* SrvClup_t)(TSeqCollection *)
Definition: TServerSocket.h:38
void operator=(const TServerSocket &)
Mother of all ROOT objects.
Definition: TObject.h:37
Bool_t Authenticate(TSocket *)
Check authentication request from the client on new open connection.
static UChar_t GetAcceptOptions()
Return default options for Accept.
static void ShowAcceptOptions()
Print default options for Accept.
static SrvAuth_t fgSrvAuthHook
Definition: TServerSocket.h:48
static SrvClup_t fgSrvAuthClupHook
Definition: TServerSocket.h:49
unsigned char UChar_t
Definition: RtypesCore.h:34
Int_t SendObject(const TObject *, Int_t=kMESS_OBJECT)
Send an object.
Definition: TServerSocket.h:78