Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPSocket.h
Go to the documentation of this file.
1// @(#)root/net:$Id$
2// Author: Fons Rademakers 20/1/2001
3
4/*************************************************************************
5 * Copyright (C) 1995-2001, 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_TPSocket
13#define ROOT_TPSocket
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TPSocket //
19// //
20// This class implements parallel client sockets. A parallel socket is //
21// an endpoint for communication between two machines. It is parallel //
22// because several TSockets are open at the same time to the same //
23// destination. This especially speeds up communication over Big Fat //
24// Pipes (i.e. high bandwidth, high latency WAN connections). //
25// //
26//////////////////////////////////////////////////////////////////////////
27
28#include "TSocket.h"
29
30class TMonitor;
31
32
33class TPSocket : public TSocket {
34
35friend class TPServerSocket;
36
37private:
38 TSocket **fSockets = nullptr; // array of parallel sockets
39 TMonitor *fWriteMonitor = nullptr; // monitor write on parallel sockets
40 TMonitor *fReadMonitor = nullptr; // monitor read from parallel sockets
41 Int_t fSize; // number of parallel sockets
42 Int_t *fWriteBytesLeft = nullptr; // bytes left to write for specified socket
43 Int_t *fReadBytesLeft = nullptr; // bytes left to read for specified socket
44 char **fWritePtr = nullptr; // pointer to write buffer for specified socket
45 char **fReadPtr = nullptr; // pointer to read buffer for specified socket
46
47 TPSocket(TSocket *pSockets[], Int_t size);
48 TPSocket(const TPSocket &) = delete;
49 void operator=(const TPSocket &) = delete;
50 void Init(Int_t tcpwindowsize, TSocket *sock = nullptr);
51 Option_t *GetOption() const override { return TObject::GetOption(); }
52
53public:
54 TPSocket(TInetAddress address, const char *service, Int_t size,
55 Int_t tcpwindowsize = -1);
56 TPSocket(TInetAddress address, Int_t port, Int_t size,
57 Int_t tcpwindowsize = -1);
58 TPSocket(const char *host, const char *service, Int_t size,
59 Int_t tcpwindowsize = -1);
60 TPSocket(const char *host, Int_t port, Int_t size, Int_t tcpwindowsize = -1);
61 TPSocket(const char *host, Int_t port, Int_t size, TSocket *sock);
62 virtual ~TPSocket();
63
64 void Close(Option_t *opt="") override;
65 Int_t GetDescriptor() const override;
67
68 Int_t Send(const TMessage &mess) override;
69 Int_t Send(Int_t kind) override { return TSocket::Send(kind); }
70 Int_t Send(Int_t status, Int_t kind) override { return TSocket::Send(status, kind); }
71 Int_t Send(const char *mess, Int_t kind = kMESS_STRING) override { return TSocket::Send(mess, kind); }
72 Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt = kDefault) override;
73 Int_t Recv(TMessage *&mess) override;
74 Int_t Recv(Int_t &status, Int_t &kind) override { return TSocket::Recv(status, kind); }
75 Int_t Recv(char *mess, Int_t max) override { return TSocket::Recv(mess, max); }
76 Int_t Recv(char *mess, Int_t max, Int_t &kind) override { return TSocket::Recv(mess, max, kind); }
77 Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt = kDefault) override;
78
79 Bool_t IsValid() const override { return fSockets ? kTRUE : kFALSE; }
80 Int_t GetErrorCode() const;
81 Int_t SetOption(ESockOptions opt, Int_t val) override;
82 Int_t GetOption(ESockOptions opt, Int_t &val) override;
83 Int_t GetSize() const { return fSize; }
84
85 ClassDefOverride(TPSocket,0) // Parallel client socket
86};
87
88#endif
@ kMESS_STRING
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
ESockOptions
Definition TSystem.h:219
ESendRecvOptions
Definition TSystem.h:232
@ kDefault
Definition TSystem.h:233
This class represents an Internet Protocol (IP) address.
virtual Option_t * GetOption() const
Definition TObject.h:139
Int_t Recv(char *mess, Int_t max) override
Receive a character string message of maximum max length.
Definition TPSocket.h:75
TPSocket(const TPSocket &)=delete
void operator=(const TPSocket &)=delete
Int_t Send(const TMessage &mess) override
Send a TMessage object.
Definition TPSocket.cxx:483
Int_t Recv(TMessage *&mess) override
Receive a TMessage object.
Definition TPSocket.cxx:626
Int_t fSize
Definition TPSocket.h:41
Int_t GetSize() const
Definition TPSocket.h:83
char ** fReadPtr
Definition TPSocket.h:45
Int_t Recv(char *mess, Int_t max, Int_t &kind) override
Receive a character string message of maximum max length.
Definition TPSocket.h:76
TMonitor * fWriteMonitor
Definition TPSocket.h:39
void Close(Option_t *opt="") override
Close a parallel socket.
Definition TPSocket.cxx:326
virtual ~TPSocket()
Cleanup the parallel socket.
Definition TPSocket.cxx:308
void Init(Int_t tcpwindowsize, TSocket *sock=nullptr)
Create a parallel socket to the specified host.
Definition TPSocket.cxx:356
TMonitor * fReadMonitor
Definition TPSocket.h:40
Int_t GetErrorCode() const
Returns error code.
Definition TPSocket.cxx:783
Int_t SetOption(ESockOptions opt, Int_t val) override
Set socket options.
Definition TPSocket.cxx:754
Int_t Send(const char *mess, Int_t kind=kMESS_STRING) override
Send a character string buffer.
Definition TPSocket.h:71
TInetAddress GetLocalInetAddress() override
Return internet address of local host to which the socket is bound.
Definition TPSocket.cxx:451
Int_t Send(Int_t kind) override
Send a single message opcode.
Definition TPSocket.h:69
Int_t Recv(Int_t &status, Int_t &kind) override
Receives a status and a message type.
Definition TPSocket.h:74
Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault) override
Send a raw buffer of specified length.
Definition TPSocket.cxx:679
char ** fWritePtr
Definition TPSocket.h:44
Int_t Send(Int_t status, Int_t kind) override
Send a status and a single message opcode.
Definition TPSocket.h:70
Option_t * GetOption() const override
Definition TPSocket.h:51
Int_t * fWriteBytesLeft
Definition TPSocket.h:42
Int_t * fReadBytesLeft
Definition TPSocket.h:43
Int_t GetDescriptor() const override
Return socket descriptor.
Definition TPSocket.cxx:467
Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault) override
Send a raw buffer of specified length.
Definition TPSocket.cxx:545
Bool_t IsValid() const override
Definition TPSocket.h:79
TSocket ** fSockets
Definition TPSocket.h:38
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Definition TSocket.cxx:818
virtual Int_t Send(const TMessage &mess)
Send a TMessage object.
Definition TSocket.cxx:522