Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPSocket.cxx
Go to the documentation of this file.
1// @(#)root/net:$Id$
2// Author: Fons Rademakers 22/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/**
13\file TPSocket.cxx
14\class TPSocket
15\brief This class implements parallel server sockets.
16\note This class deals with sockets: the user is entirely responsible for the security of their usage, for example, but
17not limited to, the management of the connections to said sockets.
18
19A parallel socket is an endpoint for communication between two machines. It is parallel
20because several TSockets are open at the same time to the same
21destination. This especially speeds up communication over Big Fat
22Pipes (i.e. high bandwidth, high latency WAN connections).
23
24**/
25
26#include "TPSocket.h"
27#include "TUrl.h"
28#include "TServerSocket.h"
29#include "TMonitor.h"
30#include "TSystem.h"
31#include "TMessage.h"
32#include "Bytes.h"
33#include "TROOT.h"
34#include "TError.h"
35#include "TVirtualMutex.h"
36
37
39#include <limits>
40
41////////////////////////////////////////////////////////////////////////////////
42/// Create a parallel socket. Connect to the named service at address addr.
43/// Use tcpwindowsize to specify the size of the receive buffer, it has
44/// to be specified here to make sure the window scale option is set (for
45/// tcpwindowsize > 65KB and for platforms supporting window scaling).
46/// Returns when connection has been accepted by remote side. Use IsValid()
47/// to check the validity of the socket. Every socket is added to the TROOT
48/// sockets list which will make sure that any open sockets are properly
49/// closed on program termination.
50
57
58////////////////////////////////////////////////////////////////////////////////
59/// Create a parallel socket. Connect to the specified port # at address addr.
60/// Use tcpwindowsize to specify the size of the receive buffer, it has
61/// to be specified here to make sure the window scale option is set (for
62/// tcpwindowsize > 65KB and for platforms supporting window scaling).
63/// Returns when connection has been accepted by remote side. Use IsValid()
64/// to check the validity of the socket. Every socket is added to the TROOT
65/// sockets list which will make sure that any open sockets are properly
66/// closed on program termination.
67
74
75////////////////////////////////////////////////////////////////////////////////
76/// Create a parallel socket. Connect to named service on the remote host.
77/// Use tcpwindowsize to specify the size of the receive buffer, it has
78/// to be specified here to make sure the window scale option is set (for
79/// tcpwindowsize > 65KB and for platforms supporting window scaling).
80/// Returns when connection has been accepted by remote side. Use IsValid()
81/// to check the validity of the socket. Every socket is added to the TROOT
82/// sockets list which will make sure that any open sockets are properly
83/// closed on program termination.
84
85TPSocket::TPSocket(const char *host, const char *service, Int_t size,
87{
88 fSize = size;
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// Create a parallel socket. Connect to specified port # on the remote host.
94/// Use tcpwindowsize to specify the size of the receive buffer, it has
95/// to be specified here to make sure the window scale option is set (for
96/// tcpwindowsize > 65KB and for platforms supporting window scaling).
97/// Returns when connection has been accepted by remote side. Use IsValid()
98/// to check the validity of the socket. Every socket is added to the TROOT
99/// sockets list which will make sure that any open sockets are properly
100/// closed on program termination.
101
102TPSocket::TPSocket(const char *host, Int_t port, Int_t size,
104 : TSocket(host, port, (Int_t)(size > 1 ? -1 : tcpwindowsize))
105{
106 // set to the real value only at end (except for old servers)
107 fSize = 1;
108
109 // to control the flow
111
112 // check if we are called from CreateAuthSocket()
114 char *pauth = (char *)strstr(host, "?A");
115 if (pauth) {
116 authreq = kTRUE;
117 }
118
119 // perhaps we can use fServType here ... to be checked
120 Bool_t rootdSrv = (strstr(host,"rootd")) ? kTRUE : kFALSE;
121
122 // try authentication , if required
123 if (authreq) {
124 if (valid) {
125 if (!Authenticate(TUrl(host).GetUser())) {
126 if (rootdSrv && (fRemoteProtocol > 0 && fRemoteProtocol < 10)) {
127 // We failed because we are talking to an old
128 // server: we need to re-open the connection
129 // and communicate the size first
130 Int_t tcpw = (size > 1 ? -1 : tcpwindowsize);
131 TSocket *ns = new TSocket(host, port, tcpw);
132 if (ns->IsValid()) {
134 gROOT->GetListOfSockets()->Remove(ns);
135 fSocket = ns->GetDescriptor();
136 fSize = size;
138 }
139 if ((valid = IsValid())) {
140 if (!Authenticate(TUrl(host).GetUser())) {
142 valid = kFALSE;
143 }
144 }
145 } else {
147 valid = kFALSE;
148 }
149 }
150 }
151 // reset url to the original state
152 *pauth = '\0';
153 SetUrl(host);
154 }
155
156 // open the sockets ...
157 if (!rootdSrv || fRemoteProtocol > 9) {
158 if (valid) {
159 fSize = size;
161 }
162 }
163}
164
165////////////////////////////////////////////////////////////////////////////////
166/// Create a parallel socket on a connection already opened via
167/// TSocket sock.
168/// This constructor is provided to optimize TNetFile opening when
169/// instatiated via a call to TNetXNGFile.
170/// Returns when connection has been accepted by remote side. Use IsValid()
171/// to check the validity of the socket. Every socket is added to the TROOT
172/// sockets list which will make sure that any open sockets are properly
173/// closed on program termination.
174
175TPSocket::TPSocket(const char *host, Int_t port, Int_t size, TSocket *sock)
176{
177 // To avoid uninitialization problems when Init is not called ...
178 fSockets = 0;
179 fWriteMonitor = 0;
180 fReadMonitor = 0;
181 fWriteBytesLeft = 0;
182 fReadBytesLeft = 0;
183 fWritePtr = 0;
184 fReadPtr = 0;
185
186 // set to the real value only at end (except for old servers)
187 fSize = 1;
188
189 // We need a opened connection
190 if (!sock) return;
191
192 // Now import existing socket info
193 fSocket = sock->GetDescriptor();
194 fService = sock->GetService();
195 fAddress = sock->GetInetAddress();
197 fBytesSent = sock->GetBytesSent();
198 fBytesRecv = sock->GetBytesRecv();
200 fSecContext = sock->GetSecContext();
204
205 // to control the flow
206 Bool_t valid = sock->IsValid();
207
208 // check if we are called from CreateAuthSocket()
210 char *pauth = (char *)strstr(host, "?A");
211 if (pauth) {
212 authreq = kTRUE;
213 }
214
215 // perhaps we can use fServType here ... to be checked
216 Bool_t rootdSrv = (strstr(host,"rootd")) ? kTRUE : kFALSE;
217
218 // try authentication , if required
219 if (authreq) {
220 if (valid) {
221 if (!Authenticate(TUrl(host).GetUser())) {
222 if (rootdSrv && (fRemoteProtocol > 0 && fRemoteProtocol < 10)) {
223 // We failed because we are talking to an old
224 // server: we need to re-open the connection
225 // and communicate the size first
226 Int_t tcpw = (size > 1 ? -1 : fTcpWindowSize);
227 TSocket *ns = new TSocket(host, port, tcpw);
228 if (ns->IsValid()) {
230 gROOT->GetListOfSockets()->Remove(ns);
231 fSocket = ns->GetDescriptor();
232 fSize = size;
234 }
235 if ((valid = IsValid())) {
236 if (!Authenticate(TUrl(host).GetUser())) {
238 valid = kFALSE;
239 }
240 }
241 } else {
243 valid = kFALSE;
244 }
245 }
246 }
247 // reset url to the original state
248 *pauth = '\0';
249 SetUrl(host);
250 }
251
252 // open the sockets ...
253 if (!rootdSrv || fRemoteProtocol > 9) {
254 if (valid) {
255 fSize = size;
256 Init(fTcpWindowSize, sock);
257 }
258 }
259
260 // Add to the list if everything OK
261 if (IsValid()) {
263 gROOT->GetListOfSockets()->Add(this);
264 }
265}
266
267////////////////////////////////////////////////////////////////////////////////
268/// Create a parallel socket. This ctor is called by TPServerSocket.
269
271{
273 fSize = size;
274
275 // set descriptor if simple socket (needed when created
276 // by TPServerSocket)
277 if (fSize <= 1)
279
280 // set socket options (no blocking and no delay)
282 if (fSize > 1)
284
289 fWritePtr = new char*[fSize];
290 fReadPtr = new char*[fSize];
291
292 for (int i = 0; i < fSize; i++) {
295 }
298
299 SetName(fSockets[0]->GetName());
302
303 {
305 gROOT->GetListOfSockets()->Add(this);
306 }
307}
308
309////////////////////////////////////////////////////////////////////////////////
310/// Cleanup the parallel socket.
311
313{
314 Close();
315
316 delete fWriteMonitor;
317 delete fReadMonitor;
318 delete [] fWriteBytesLeft;
319 delete [] fReadBytesLeft;
320 delete [] fWritePtr;
321 delete [] fReadPtr;
322}
323
324////////////////////////////////////////////////////////////////////////////////
325/// Close a parallel socket. If option is "force", calls shutdown(id,2) to
326/// shut down the connection. This will close the connection also
327/// for the parent of this process. Also called via the dtor (without
328/// option "force", call explicitly Close("force") if this is desired).
329
331{
332
333 if (!IsValid()) {
334 // if closing happens too early (e.g. timeout) the underlying
335 // socket may still be open
337 return;
338 }
339
340 if (fSize <= 1) {
342 } else {
343 for (int i = 0; i < fSize; i++) {
344 fSockets[i]->Close(option);
345 delete fSockets[i];
346 }
347 }
348 delete [] fSockets;
349 fSockets = 0;
350
351 {
353 gROOT->GetListOfSockets()->Remove(this);
354 }
355}
356
357////////////////////////////////////////////////////////////////////////////////
358/// Create a parallel socket to the specified host.
359
361{
362 fSockets = 0;
363 fWriteMonitor = 0;
364 fReadMonitor = 0;
365 fWriteBytesLeft = 0;
366 fReadBytesLeft = 0;
367 fWritePtr = 0;
368 fReadPtr = 0;
369
370 if ((sock && !sock->IsValid()) || !TSocket::IsValid())
371 return;
372
373 Int_t i = 0;
374
375 if (fSize <= 1) {
376 // check if single mode
377 fSize = 1;
378
379 // set socket options (no delay)
380 if (sock)
381 sock->SetOption(kNoDelay, 1);
382 else
384
385 // if yes, communicate this to server
386 // (size = 0 for backward compatibility)
387 if (sock) {
388 if (sock->Send((Int_t)0, (Int_t)0) < 0)
389 Warning("Init", "%p: problems sending (0,0)", sock);
390 } else {
391 if (TSocket::Send((Int_t)0, (Int_t)0) < 0)
392 Warning("Init", "problems sending (0,0)");
393 }
394
395 // needs to fill additional private members
396 fSockets = new TSocket*[1];
397 fSockets[0]= (TSocket *)this;
398
399 } else {
400
401 // create server that will be used to accept the parallel sockets from
402 // the remote host, use port=0 to scan for a free port
404
405 // send the local port number of the just created server socket and the
406 // number of desired parallel sockets
407 if (sock) {
408 if (sock->Send(ss.GetLocalPort(), fSize) < 0)
409 Warning("Init", "%p: problems sending size", sock);
410 } else {
411 if (TSocket::Send(ss.GetLocalPort(), fSize) < 0)
412 Warning("Init", "problems sending size");
413 }
414
415 fSockets = new TSocket*[fSize];
416
417 // establish fSize parallel socket connections between client and server
418 for (i = 0; i < fSize; i++) {
419 fSockets[i] = ss.Accept();
421 gROOT->GetListOfSockets()->Remove(fSockets[i]);
422 }
423
424 // set socket options (no blocking and no delay)
427
428 // close original socket
429 if (sock)
430 sock->Close();
431 else
433 fSocket = -1;
434 }
435
440 fWritePtr = new char*[fSize];
441 fReadPtr = new char*[fSize];
442
443 for (i = 0; i < fSize; i++) {
446 }
449}
450
451////////////////////////////////////////////////////////////////////////////////
452/// Return internet address of local host to which the socket is bound.
453/// In case of error TInetAddress::IsValid() returns kFALSE.
454
456{
457 if (fSize<= 1)
459
460 if (IsValid()) {
461 if (fLocalAddress.GetPort() == -1)
463 return fLocalAddress;
464 }
465 return TInetAddress();
466}
467
468////////////////////////////////////////////////////////////////////////////////
469/// Return socket descriptor
470
472{
473 if (fSize <= 1)
474 return TSocket::GetDescriptor();
475
476 return fSockets ? fSockets[0]->GetDescriptor() : -1;
477
478}
479
480////////////////////////////////////////////////////////////////////////////////
481/// Send a TMessage object. Returns the number of bytes in the TMessage
482/// that were sent and -1 in case of error. In case the TMessage::What
483/// has been or'ed with kMESS_ACK, the call will only return after having
484/// received an acknowledgement, making the sending process synchronous.
485/// Returns -4 in case of kNoBlock and errno == EWOULDBLOCK.
486
488{
489 if (!fSockets || fSize <= 1)
490 return TSocket::Send(mess); // only the case when called via Init()
491
492 if (!IsValid()) {
493 return -1;
494 }
495
496 if (mess.IsReading()) {
497 Error("Send", "cannot send a message used for reading");
498 return -1;
499 }
500
501 // send streamer infos in case schema evolution is enabled in the TMessage
503
504 // send the process id's so TRefs work
506
507 mess.SetLength(); //write length in first word of buffer
508
509 if (GetCompressionLevel() > 0 && mess.GetCompressionLevel() == 0)
511
512 if (mess.GetCompressionLevel() > 0)
513 const_cast<TMessage&>(mess).Compress();
514
515 char *mbuf = mess.Buffer();
516 Int_t mlen = mess.Length();
517 if (mess.CompBuffer()) {
518 mbuf = mess.CompBuffer();
519 mlen = mess.CompLength();
520 }
521
522 Int_t nsent, ulen = (Int_t) sizeof(UInt_t);
523 // send length
524 if ((nsent = SendRaw(mbuf, ulen, kDefault)) <= 0)
525 return nsent;
526
527 // send buffer (this might go in parallel)
528 if ((nsent = SendRaw(mbuf+ulen, mlen-ulen, kDefault)) <= 0)
529 return nsent;
530
531 // if acknowledgement is desired, wait for it
532 if (mess.What() & kMESS_ACK) {
533 char buf[2];
534 if (RecvRaw(buf, sizeof(buf), kDefault) < 0)
535 return -1;
536 if (strncmp(buf, "ok", 2)) {
537 Error("Send", "bad acknowledgement");
538 return -1;
539 }
540 }
541
542 return nsent; //length - length header
543}
544
545////////////////////////////////////////////////////////////////////////////////
546/// Send a raw buffer of specified length. Returns the number of bytes
547/// send and -1 in case of error.
548
550{
551 if (fSize == 1)
552 return TSocket::SendRaw(buffer,length,opt);
553
554 if (!fSockets) return -1;
555
556 // if data buffer size < 4K use only one socket
557 Int_t i, nsocks = fSize, len = length;
558 if (len < 4096)
559 nsocks = 1;
560
562 if (nsocks == 1)
564
565 if (opt != kDefault) {
566 nsocks = 1;
567 sendopt = opt;
568 }
569
570 if (nsocks == 1)
572 else
574
575 // setup pointer appropriately for transferring data equally on the
576 // parallel sockets
577 for (i = 0; i < nsocks; i++) {
579 fWritePtr[i] = (char *)buffer + (i*fWriteBytesLeft[i]);
581 }
583
584 // send the data on the parallel sockets
585 while (len > 0) {
587 for (int is = 0; is < nsocks; is++) {
588 if (s == fSockets[is]) {
589 if (fWriteBytesLeft[is] > 0) {
590 Int_t nsent;
591again:
595 sendopt)) <= 0) {
596 if (nsent == -4) {
597 // got EAGAIN/EWOULDBLOCK error, keep trying...
598 goto again;
599 }
601 if (nsent == -5) {
602 // connection reset by peer or broken ...
604 Close();
605 }
606 return -1;
607 }
608 if (opt == kDontBlock) {
610 return nsent;
611 }
613 fWritePtr[is] += nsent;
614 len -= nsent;
615 }
616 }
617 }
618 }
620
621 return length;
622}
623
624////////////////////////////////////////////////////////////////////////////////
625/// Receive a TMessage object. The user must delete the TMessage object.
626/// Returns length of message in bytes (can be 0 if other side of connection
627/// is closed) or -1 in case of error or -4 in case a non-blocking socket would
628/// block (i.e. there is nothing to be read). In those case mess == 0.
629
631{
632 if (fSize <= 1)
633 return TSocket::Recv(mess);
634
635 if (!IsValid()) {
636 mess = 0;
637 return -1;
638 }
639
641 Int_t n;
642 UInt_t len;
643 if ((n = RecvRaw(&len, sizeof(UInt_t), kDefault)) <= 0) {
644 mess = 0;
645 return n;
646 }
647 len = net2host(len); //from network to host byte order
648
649 if (len > (std::numeric_limits<decltype(len)>::max() - sizeof(decltype(len)))) {
650 Error("Recv", "Buffer length is %u and %u+sizeof(UInt_t) cannot be represented as an UInt_t.", len, len);
651 return -1;
652 }
653
654 char *buf = new char[len+sizeof(UInt_t)];
655 if ((n = RecvRaw(buf+sizeof(UInt_t), len, kDefault)) <= 0) {
656 delete [] buf;
657 mess = 0;
658 return n;
659 }
660
661 mess = new TMessage(buf, len+sizeof(UInt_t));
662
663 // receive any streamer infos
665 goto oncemore;
666
667 // receive any process ids
668 if (RecvProcessIDs(mess))
669 goto oncemore;
670
671 if (mess->What() & kMESS_ACK) {
672 char ok[2] = { 'o', 'k' };
673 if (SendRaw(ok, sizeof(ok), kDefault) < 0) {
674 delete mess;
675 mess = 0;
676 return -1;
677 }
678 mess->SetWhat(mess->What() & ~kMESS_ACK);
679 }
680
681 return n;
682}
683
684////////////////////////////////////////////////////////////////////////////////
685/// Send a raw buffer of specified length. Returns the number of bytes
686/// sent or -1 in case of error.
687
689{
690 if (fSize <= 1)
691 return TSocket::RecvRaw(buffer,length,opt);
692
693 if (!fSockets) return -1;
694
695 // if data buffer size < 4K use only one socket
696 Int_t i, nsocks = fSize, len = length;
697 if (len < 4096)
698 nsocks = 1;
699
701 if (nsocks == 1)
703
704 if (opt != kDefault) {
705 nsocks = 1;
706 recvopt = opt;
707 }
708
709 if (nsocks == 1)
711 else
713
714 // setup pointer appropriately for transferring data equally on the
715 // parallel sockets
716 for (i = 0; i < nsocks; i++) {
718 fReadPtr[i] = (char *)buffer + (i*fReadBytesLeft[i]);
720 }
722
723 // start receiving data on all sockets. Receive data as and when
724 // they are available on a socket by by using select.
725 // Exit the loop as soon as all data has been received.
726 while (len > 0) {
728 for (int is = 0; is < nsocks; is++) {
729 if (s == fSockets[is]) {
730 if (fReadBytesLeft[is] > 0) {
731 Int_t nrecv;
735 recvopt)) <= 0) {
737 if (nrecv == -5) {
738 // connection reset by peer or broken ...
740 Close();
741 }
742 return -1;
743 }
744 if (opt == kDontBlock) {
746 return nrecv;
747 }
749 fReadPtr[is] += nrecv;
750 len -= nrecv;
751 }
752 }
753 }
754 }
756
757 return length;
758}
759
760////////////////////////////////////////////////////////////////////////////////
761/// Set socket options.
762
764{
765 if (fSize <= 1)
766 return TSocket::SetOption(opt,val);
767
768 Int_t ret = 0;
769 for (int i = 0; i < fSize; i++)
770 ret = fSockets[i]->SetOption(opt, val);
771 return ret;
772}
773
774////////////////////////////////////////////////////////////////////////////////
775/// Get socket options. Returns -1 in case of error.
776
778{
779 if (fSize <= 1)
780 return TSocket::GetOption(opt,val);
781
782 Int_t ret = 0;
783 for (int i = 0; i < fSize; i++)
784 ret = fSockets[i]->GetOption(opt, val);
785 return ret;
786}
787
788////////////////////////////////////////////////////////////////////////////////
789/// Returns error code. Meaning depends on context where it is called.
790/// If no error condition returns 0 else a value < 0.
791
793{
794 if (fSize <= 1)
795 return TSocket::GetErrorCode();
796
797 return fSockets[0] ? fSockets[0]->GetErrorCode() : 0;
798}
UShort_t net2host(UShort_t x)
Definition Bytes.h:575
@ kMESS_ACK
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
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 ClassImp(name)
Definition Rtypes.h:374
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t option
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
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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
const char * GetUser() const
Definition TProof.h:589
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:414
ESockOptions
Definition TSystem.h:229
@ kNoBlock
Definition TSystem.h:236
@ kNoDelay
Definition TSystem.h:235
ESendRecvOptions
Definition TSystem.h:242
@ kDontBlock
Definition TSystem.h:246
@ kDefault
Definition TSystem.h:243
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define R__LOCKGUARD(mutex)
This class represents an Internet Protocol (IP) address.
Int_t GetPort() const
Int_t Compress()
Compress the message.
Definition TMessage.cxx:319
TSocket * Select()
Return pointer to socket for which an event is waiting.
Definition TMonitor.cxx:322
virtual void Activate(TSocket *sock)
Activate a de-activated socket.
Definition TMonitor.cxx:250
virtual void Add(TSocket *sock, Int_t interest=kRead)
Add socket to the monitor's active list.
Definition TMonitor.cxx:168
virtual void DeActivateAll()
De-activate all activated sockets.
Definition TMonitor.cxx:302
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:174
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:150
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1057
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:864
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
void ResetBit(UInt_t f)
Definition TObject.h:204
This class implements parallel server sockets.
Definition TPSocket.h:33
Int_t Send(const TMessage &mess) override
Send a TMessage object.
Definition TPSocket.cxx:487
Int_t Recv(TMessage *&mess) override
Receive a TMessage object.
Definition TPSocket.cxx:630
TPSocket(TSocket *pSockets[], Int_t size)
Create a parallel socket. This ctor is called by TPServerSocket.
Definition TPSocket.cxx:270
Int_t fSize
Definition TPSocket.h:41
char ** fReadPtr
Definition TPSocket.h:45
TMonitor * fWriteMonitor
Definition TPSocket.h:39
void Close(Option_t *opt="") override
Close a parallel socket.
Definition TPSocket.cxx:330
virtual ~TPSocket()
Cleanup the parallel socket.
Definition TPSocket.cxx:312
void Init(Int_t tcpwindowsize, TSocket *sock=nullptr)
Create a parallel socket to the specified host.
Definition TPSocket.cxx:360
TMonitor * fReadMonitor
Definition TPSocket.h:40
Int_t GetErrorCode() const
Returns error code.
Definition TPSocket.cxx:792
Int_t SetOption(ESockOptions opt, Int_t val) override
Set socket options.
Definition TPSocket.cxx:763
TInetAddress GetLocalInetAddress() override
Return internet address of local host to which the socket is bound.
Definition TPSocket.cxx:455
Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault) override
Send a raw buffer of specified length.
Definition TPSocket.cxx:688
char ** fWritePtr
Definition TPSocket.h:44
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:471
Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault) override
Send a raw buffer of specified length.
Definition TPSocket.cxx:549
Bool_t IsValid() const override
Definition TPSocket.h:79
TSocket ** fSockets
Definition TPSocket.h:38
This class implements server sockets.
This class implements client sockets.
Definition TSocket.h:41
TInetAddress fAddress
Definition TSocket.h:59
Int_t fCompress
Definition TSocket.h:62
virtual Int_t SetOption(ESockOptions opt, Int_t val)
Set socket options.
Definition TSocket.cxx:1020
Int_t fSocket
Definition TSocket.h:69
Int_t GetErrorCode() const
Returns error code.
Definition TSocket.cxx:1042
UInt_t GetBytesRecv() const
Definition TSocket.h:120
void SendStreamerInfos(const TMessage &mess)
Check if TStreamerInfo must be sent.
Definition TSocket.cxx:651
const char * GetService() const
Definition TSocket.h:116
TSocket()
Definition TSocket.h:83
TString fService
Definition TSocket.h:67
Bool_t RecvStreamerInfos(TMessage *mess)
Receive a message containing streamer infos.
Definition TSocket.cxx:935
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Definition TSocket.cxx:820
Int_t GetRemoteProtocol() const
Definition TSocket.h:126
UInt_t GetBytesSent() const
Definition TSocket.h:119
Bool_t Authenticate(const char *user)
Authenticated the socket with specified user.
Definition TSocket.cxx:1113
TInetAddress fLocalAddress
Definition TSocket.h:63
Int_t GetTcpWindowSize() const
Definition TSocket.h:128
@ kBrokenConn
Definition TSocket.h:49
virtual void Close(Option_t *opt="")
Close the socket.
Definition TSocket.cxx:391
Bool_t RecvProcessIDs(TMessage *mess)
Receive a message containing process ids.
Definition TSocket.cxx:982
void SetUrl(const char *url)
Definition TSocket.h:155
TInetAddress GetInetAddress() const
Definition TSocket.h:113
Int_t GetCompressionLevel() const
Definition TSocket.h:181
virtual Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
Definition TSocket.cxx:905
TSecContext * GetSecContext() const
Definition TSocket.h:127
virtual Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Send a raw buffer of specified length.
Definition TSocket.cxx:622
void SendProcessIDs(const TMessage &mess)
Check if TProcessIDs must be sent.
Definition TSocket.cxx:686
virtual TInetAddress GetLocalInetAddress()
Return internet address of local host to which the socket is bound.
Definition TSocket.cxx:411
TSecContext * fSecContext
Definition TSocket.h:65
Int_t fTcpWindowSize
Definition TSocket.h:70
Option_t * GetOption() const override
Definition TSocket.h:98
EServiceType
Definition TSocket.h:52
virtual Int_t GetDescriptor() const
Definition TSocket.h:112
Int_t GetCompressionSettings() const
Definition TSocket.h:187
Int_t GetServType() const
Definition TSocket.h:117
EServiceType fServType
Definition TSocket.h:68
void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Used to specify the compression level and algorithm: settings = 100 * algorithm + level.
Definition TSocket.cxx:1105
UInt_t fBytesSent
Definition TSocket.h:61
Int_t fRemoteProtocol
Definition TSocket.h:64
UInt_t fBytesRecv
Definition TSocket.h:60
virtual Bool_t IsValid() const
Definition TSocket.h:132
virtual Int_t Send(const TMessage &mess)
Send a TMessage object.
Definition TSocket.cxx:524
virtual TInetAddress GetSockName(int sock)
Get Internet Protocol (IP) address of host and port #.
Definition TSystem.cxx:2321
virtual void CloseConnection(int sock, Bool_t force=kFALSE)
Close socket connection.
Definition TSystem.cxx:2402
This class represents a WWW compatible URL.
Definition TUrl.h:33
const Int_t n
Definition legend1.C:16