Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include "TSocket.h"
29#include <string>
30
31class TSeqCollection;
32
33typedef Int_t (*SrvAuth_t)(TSocket *sock, const char *, const char *,
34 std::string&, Int_t &, Int_t &, std::string &,
37
38// These mask are globally available to manipulate the option to Accept
39const UChar_t kSrvAuth = 0x1; // Require client authentication
40const UChar_t kSrvNoAuth = (kSrvAuth<<4); // Force no client authentication
41
42class TServerSocket : public TSocket {
43
44private:
45 TSeqCollection *fSecContexts; // List of TSecContext with cleanup info
48 static UChar_t fgAcceptOpt; // Default accept options
49
52 void operator=(const TServerSocket &);
54
55public:
56 enum { kDefaultBacklog = 10 };
57
58 TServerSocket(Int_t port, Bool_t reuse = kFALSE, Int_t backlog = kDefaultBacklog,
59 Int_t tcpwindowsize = -1);
60 TServerSocket(const char *service, Bool_t reuse = kFALSE,
61 Int_t backlog = kDefaultBacklog, Int_t tcpwindowsize = -1);
62 virtual ~TServerSocket();
63
64 virtual TSocket *Accept(UChar_t Opt = 0);
66 Int_t GetLocalPort() override;
67
68 Int_t Send(const TMessage &) override
69 { MayNotUse("Send(const TMessage &)"); return 0; }
70 Int_t Send(Int_t) override
71 { MayNotUse("Send(Int_t)"); return 0; }
72 Int_t Send(Int_t, Int_t) override
73 { MayNotUse("Send(Int_t, Int_t)"); return 0; }
74 Int_t Send(const char *, Int_t = kMESS_STRING) override
75 { MayNotUse("Send(const char *, Int_t)"); return 0; }
77 { MayNotUse("SendObject(const TObject *, Int_t)"); return 0; }
78 Int_t SendRaw(const void *, Int_t, ESendRecvOptions = kDefault) override
79 { MayNotUse("SendRaw(const void *, Int_t, ESendRecvOptions)"); return 0; }
80 Int_t Recv(TMessage *&) override
81 { MayNotUse("Recv(TMessage *&)"); return 0; }
82 Int_t Recv(Int_t &, Int_t &) override
83 { MayNotUse("Recv(Int_t &, Int_t &)"); return 0; }
84 Int_t Recv(char *, Int_t) override
85 { MayNotUse("Recv(char *, Int_t)"); return 0; }
86 Int_t Recv(char *, Int_t, Int_t &) override
87 { MayNotUse("Recv(char *, Int_t, Int_t &)"); return 0; }
89 { MayNotUse("RecvRaw(void *, Int_t, ESendRecvOptions)"); return 0; }
90
92 static void SetAcceptOptions(UChar_t Opt);
93 static void ShowAcceptOptions();
94
95 ClassDefOverride(TServerSocket, 0); //This class implements server sockets
96};
97
98#endif
@ kMESS_STRING
@ kMESS_OBJECT
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned char UChar_t
Definition RtypesCore.h:38
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Int_t(* SrvClup_t)(TSeqCollection *)
const UChar_t kSrvNoAuth
const UChar_t kSrvAuth
Int_t(* SrvAuth_t)(TSocket *sock, const char *, const char *, std::string &, Int_t &, Int_t &, std::string &, TSeqCollection *)
ESendRecvOptions
Definition TSystem.h:226
@ kDefault
Definition TSystem.h:227
This class represents an Internet Protocol (IP) address.
Mother of all ROOT objects.
Definition TObject.h:41
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:1040
Sequenceable collection abstract base class.
Int_t Recv(char *, Int_t) override
Receive a character string message of maximum max length.
Int_t Recv(Int_t &, Int_t &) override
Receives a status and a message type.
static SrvAuth_t fgSrvAuthHook
TServerSocket(const TServerSocket &)
Int_t Send(Int_t) override
Send a single message opcode.
Int_t Send(Int_t, Int_t) override
Send a status and a single message opcode.
static UChar_t fgAcceptOpt
Int_t Recv(char *, Int_t, Int_t &) override
Receive a character string message of maximum max length.
static void SetAcceptOptions(UChar_t Opt)
Set default options for Accept according to modifier 'mod'.
void operator=(const TServerSocket &)
Int_t Send(const char *, Int_t=kMESS_STRING) override
Send a character string buffer.
Bool_t Authenticate(TSocket *)
Check authentication request from the client on new open connection.
Int_t RecvRaw(void *, Int_t, ESendRecvOptions=kDefault) override
Receive a raw buffer of specified length bytes.
Int_t GetLocalPort() override
Get port # to which server socket is bound. In case of error returns -1.
static SrvClup_t fgSrvAuthClupHook
virtual ~TServerSocket()
Destructor: cleanup authentication stuff (if any) and close.
static void ShowAcceptOptions()
Print default options for Accept.
Int_t Recv(TMessage *&) override
Receive a TMessage object.
static UChar_t GetAcceptOptions()
Return default options for Accept.
Int_t SendRaw(const void *, Int_t, ESendRecvOptions=kDefault) override
Send a raw buffer of specified length.
virtual TSocket * Accept(UChar_t Opt=0)
Accept a connection on a server socket.
Int_t SendObject(const TObject *, Int_t=kMESS_OBJECT) override
Send an object.
TInetAddress GetLocalInetAddress() override
Return internet address of host to which the server socket is bound, i.e.
TSeqCollection * fSecContexts
Int_t Send(const TMessage &) override
Send a TMessage object.