Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSocket.cxx
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/**
13\file TSocket.cxx
14\class TSocket
15\brief This class implements client 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 socket is an endpoint for communication between two machines. The actual work is done via the TSystem class (either
20TUnixSystem or TWinNTSystem).
21
22**/
23
24#include "Bytes.h"
25#include "Compression.h"
26#include "NetErrors.h"
27#include "TError.h"
28#include "TMessage.h"
29#include "TObjString.h"
30#include "TPSocket.h"
31#include "TPluginManager.h"
32#include "TROOT.h"
33#include "TString.h"
34#include "TSystem.h"
35#include "TUrl.h"
36#include "TVirtualAuth.h"
37#include "TStreamerInfo.h"
38#include "TProcessID.h"
39
40#include <limits>
41
44
45//
46// Client "protocol changes"
47//
48// This was in TNetFile and TAuthenticate before, but after the introduction
49// of TSocket::CreateAuthSocket the common place for all the clients is TSocket,
50// so this seems to be the right place for a version number
51//
52// 7: added support for ReOpen(), kROOTD_BYE and kROOTD_PROTOCOL2
53// 8: added support for update being a create (open stat = 2 and not 1)
54// 9: added new authentication features (see README.AUTH)
55// 10: added support for authenticated socket via TSocket::CreateAuthSocket(...)
56// 11: modified SSH protocol + support for server 'no authentication' mode
57// 12: add random tags to avoid reply attacks (password+token)
58// 13: authentication re-organization; cleanup in PROOF
59// 14: support for SSH authentication via SSH tunnel
60// 15: cope with fixes in TUrl::GetFile
61// 16: add env setup message exchange
62//
63Int_t TSocket::fgClientProtocol = 17; // increase when client protocol changes
64
66
68
69////////////////////////////////////////////////////////////////////////////////
70/// Create a socket. Connect to the named service at address addr.
71/// Use tcpwindowsize to specify the size of the receive buffer, it has
72/// to be specified here to make sure the window scale option is set (for
73/// tcpwindowsize > 65KB and for platforms supporting window scaling).
74/// Returns when connection has been accepted by remote side. Use IsValid()
75/// to check the validity of the socket. Every socket is added to the TROOT
76/// sockets list which will make sure that any open sockets are properly
77/// closed on program termination.
78
80 : TNamed(addr.GetHostName(), service), fCompress(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
81{
84
86 fSecContext = 0;
89 if (fService.Contains("root"))
91 if (fService.Contains("proof"))
93 fAddress = addr;
95 fBytesSent = 0;
96 fBytesRecv = 0;
98 fUUIDs = 0;
99 fLastUsageMtx = 0;
101
102 if (fAddress.GetPort() != -1) {
105
106 if (fSocket != kInvalid) {
107 gROOT->GetListOfSockets()->Add(this);
108 }
109 } else
111
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// Create a socket. Connect to the specified port # at address addr.
116/// Use tcpwindowsize to specify the size of the receive buffer, it has
117/// to be specified here to make sure the window scale option is set (for
118/// tcpwindowsize > 65KB and for platforms supporting window scaling).
119/// Returns when connection has been accepted by remote side. Use IsValid()
120/// to check the validity of the socket. Every socket is added to the TROOT
121/// sockets list which will make sure that any open sockets are properly
122/// closed on program termination.
123
125 : TNamed(addr.GetHostName(), ""), fCompress(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
126{
129
131 fSecContext = 0;
132 fRemoteProtocol= -1;
134 if (fService.Contains("root"))
136 if (fService.Contains("proof"))
138 fAddress = addr;
139 fAddress.fPort = port;
141 fBytesSent = 0;
142 fBytesRecv = 0;
144 fUUIDs = 0;
145 fLastUsageMtx = 0;
147
150 if (fSocket == kInvalid)
151 fAddress.fPort = -1;
152 else {
153 gROOT->GetListOfSockets()->Add(this);
154 }
155}
156
157////////////////////////////////////////////////////////////////////////////////
158/// Create a socket. Connect to named service on the remote host.
159/// Use tcpwindowsize to specify the size of the receive buffer, it has
160/// to be specified here to make sure the window scale option is set (for
161/// tcpwindowsize > 65KB and for platforms supporting window scaling).
162/// Returns when connection has been accepted by remote side. Use IsValid()
163/// to check the validity of the socket. Every socket is added to the TROOT
164/// sockets list which will make sure that any open sockets are properly
165/// closed on program termination.
166
167TSocket::TSocket(const char *host, const char *service, Int_t tcpwindowsize)
168 : TNamed(host, service), fCompress(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
169{
172
174 fSecContext = 0;
175 fRemoteProtocol= -1;
177 if (fService.Contains("root"))
179 if (fService.Contains("proof"))
184 fBytesSent = 0;
185 fBytesRecv = 0;
187 fUUIDs = 0;
188 fLastUsageMtx = 0;
190
191 if (fAddress.GetPort() != -1) {
193 if (fSocket != kInvalid) {
194 gROOT->GetListOfSockets()->Add(this);
195 }
196 } else
198}
199
200////////////////////////////////////////////////////////////////////////////////
201/// Create a socket; see CreateAuthSocket for the form of url.
202/// Connect to the specified port # on the remote host.
203/// If user is specified in url, try authentication as user.
204/// Use tcpwindowsize to specify the size of the receive buffer, it has
205/// to be specified here to make sure the window scale option is set (for
206/// tcpwindowsize > 65KB and for platforms supporting window scaling).
207/// Returns when connection has been accepted by remote side. Use IsValid()
208/// to check the validity of the socket. Every socket is added to the TROOT
209/// sockets list which will make sure that any open sockets are properly
210/// closed on program termination.
211
213 : TNamed(TUrl(url).GetHost(), ""), fCompress(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
214{
217
218 fUrl = TString(url);
219 TString host(TUrl(fUrl).GetHost());
220
222 fSecContext = 0;
223 fRemoteProtocol= -1;
225 if (fUrl.Contains("root"))
227 if (fUrl.Contains("proof"))
230 fAddress.fPort = port;
233 fBytesSent = 0;
234 fBytesRecv = 0;
236 fUUIDs = 0;
237 fLastUsageMtx = 0;
239
241 if (fSocket == kInvalid) {
243 } else {
244 gROOT->GetListOfSockets()->Add(this);
245 }
246}
247
248////////////////////////////////////////////////////////////////////////////////
249/// Create a socket in the Unix domain on 'sockpath'.
250/// Returns when connection has been accepted by the server. Use IsValid()
251/// to check the validity of the socket. Every socket is added to the TROOT
252/// sockets list which will make sure that any open sockets are properly
253/// closed on program termination.
254
256 fCompress(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
257{
260
261 fUrl = sockpath;
262
263 fService = "unix";
264 fSecContext = 0;
265 fRemoteProtocol= -1;
267 fAddress.fPort = -1;
268 fName.Form("unix:%s", sockpath);
270 fBytesSent = 0;
271 fBytesRecv = 0;
272 fTcpWindowSize = -1;
273 fUUIDs = 0;
274 fLastUsageMtx = 0;
276
278 if (fSocket > 0) {
279 gROOT->GetListOfSockets()->Add(this);
280 }
281}
282
283////////////////////////////////////////////////////////////////////////////////
284/// Create a socket. The socket will adopt previously opened TCP socket with
285/// descriptor desc.
286
287TSocket::TSocket(Int_t desc) : TNamed("", ""), fCompress(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
288{
291
292 fSecContext = 0;
293 fRemoteProtocol = 0;
294 fService = (char *)kSOCKD;
296 fBytesSent = 0;
297 fBytesRecv = 0;
298 fTcpWindowSize = -1;
299 fUUIDs = 0;
300 fLastUsageMtx = 0;
302
303 if (desc >= 0) {
304 fSocket = desc;
306 gROOT->GetListOfSockets()->Add(this);
307 } else
309}
310
311////////////////////////////////////////////////////////////////////////////////
312/// Create a socket. The socket will adopt previously opened Unix socket with
313/// descriptor desc. The sockpath arg is for info purposes only. Use
314/// this method to adopt e.g. a socket created via socketpair().
315
317 fCompress(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
318{
321
322 fUrl = sockpath;
323
324 fService = "unix";
325 fSecContext = 0;
326 fRemoteProtocol= -1;
328 fAddress.fPort = -1;
329 fName.Form("unix:%s", sockpath);
331 fBytesSent = 0;
332 fBytesRecv = 0;
333 fTcpWindowSize = -1;
334 fUUIDs = 0;
335 fLastUsageMtx = 0;
337
338 if (desc >= 0) {
339 fSocket = desc;
340 gROOT->GetListOfSockets()->Add(this);
341 } else
343}
344
345
346////////////////////////////////////////////////////////////////////////////////
347/// TSocket copy ctor.
348
350{
351 fSocket = s.fSocket;
352 fService = s.fService;
353 fAddress = s.fAddress;
362 fUUIDs = 0;
363 fLastUsageMtx = 0;
365
366 if (fSocket != kInvalid) {
367 gROOT->GetListOfSockets()->Add(this);
368 }
369}
370////////////////////////////////////////////////////////////////////////////////
371/// Close the socket and mark as due to a broken connection.
372
384
385////////////////////////////////////////////////////////////////////////////////
386/// Close the socket. If option is "force", calls shutdown(id,2) to
387/// shut down the connection. This will close the connection also
388/// for the parent of this process. Also called via the dtor (without
389/// option "force", call explicitly Close("force") if this is desired).
390
392{
393 Bool_t force = option ? (!strcmp(option, "force") ? kTRUE : kFALSE) : kFALSE;
394
395 if (fSocket != kInvalid) {
396 if (IsValid()) { // Filter out kInvalidStillInList case (disconnected but not removed from list)
398 }
399 gROOT->GetListOfSockets()->Remove(this);
400 }
402
405}
406
407////////////////////////////////////////////////////////////////////////////////
408/// Return internet address of local host to which the socket is bound.
409/// In case of error TInetAddress::IsValid() returns kFALSE.
410
412{
413 if (IsValid()) {
414 if (fLocalAddress.GetPort() == -1)
416 return fLocalAddress;
417 }
418 return TInetAddress();
419}
420
421////////////////////////////////////////////////////////////////////////////////
422/// Return the local port # to which the socket is bound.
423/// In case of error return -1.
424
426{
427 if (IsValid()) {
428 if (fLocalAddress.GetPort() == -1)
430 return fLocalAddress.GetPort();
431 }
432 return -1;
433}
434
435////////////////////////////////////////////////////////////////////////////////
436/// Waits for this socket to change status. If interest=kRead,
437/// the socket will be watched to see if characters become available for
438/// reading; if interest=kWrite the socket will be watched to
439/// see if a write will not block.
440/// The argument 'timeout' specifies a maximum time to wait in millisec.
441/// Default no timeout.
442/// Returns 1 if a change of status of interest has been detected within
443/// timeout; 0 in case of timeout; < 0 if an error occured.
444
446{
447 Int_t rc = 1;
448
449 // Associate a TFileHandler to this socket
451
452 // Wait for an event now
453 rc = gSystem->Select(&fh, timeout);
454
455 return rc;
456}
457
458////////////////////////////////////////////////////////////////////////////////
459/// Send a single message opcode. Use kind (opcode) to set the
460/// TMessage "what" field. Returns the number of bytes that were sent
461/// (always sizeof(Int_t)) and -1 in case of error. In case the kind has
462/// been or'ed with kMESS_ACK, the call will only return after having
463/// received an acknowledgement, making the sending process synchronous.
464
466{
467 TMessage mess(kind);
468
469 Int_t nsent;
470 if ((nsent = Send(mess)) < 0)
471 return -1;
472
473 return nsent;
474}
475
476////////////////////////////////////////////////////////////////////////////////
477/// Send a status and a single message opcode. Use kind (opcode) to set the
478/// TMessage "what" field. Returns the number of bytes that were sent
479/// (always 2*sizeof(Int_t)) and -1 in case of error. In case the kind has
480/// been or'ed with kMESS_ACK, the call will only return after having
481/// received an acknowledgement, making the sending process synchronous.
482
484{
485 TMessage mess(kind);
486 mess << status;
487
488 Int_t nsent;
489 if ((nsent = Send(mess)) < 0)
490 return -1;
491
492 return nsent;
493}
494
495////////////////////////////////////////////////////////////////////////////////
496/// Send a character string buffer. Use kind to set the TMessage "what" field.
497/// Returns the number of bytes in the string str that were sent and -1 in
498/// case of error. In case the kind has been or'ed with kMESS_ACK, the call
499/// will only return after having received an acknowledgement, making the
500/// sending process synchronous.
501
502Int_t TSocket::Send(const char *str, Int_t kind)
503{
504 TMessage mess(kind);
505 if (str) mess.WriteString(str);
506
507 Int_t nsent;
508 if ((nsent = Send(mess)) < 0)
509 return -1;
510
511 return nsent - sizeof(Int_t); // - TMessage::What()
512}
513
514////////////////////////////////////////////////////////////////////////////////
515/// Send a TMessage object. Returns the number of bytes in the TMessage
516/// that were sent and -1 in case of error. In case the TMessage::What
517/// has been or'ed with kMESS_ACK, the call will only return after having
518/// received an acknowledgement, making the sending process synchronous.
519/// Returns -4 in case of kNoBlock and errno == EWOULDBLOCK.
520/// Returns -5 if pipe broken or reset by peer (EPIPE || ECONNRESET).
521/// support for streaming TStreamerInfo added by Rene Brun May 2008
522/// support for streaming TProcessID added by Rene Brun June 2008
523
525{
527
528 if (fSocket < 0) return -1;
529
530 if (mess.IsReading()) {
531 Error("Send", "cannot send a message used for reading");
532 return -1;
533 }
534
535 // send streamer infos in case schema evolution is enabled in the TMessage
537
538 // send the process id's so TRefs work
540
541 mess.SetLength(); //write length in first word of buffer
542
543 if (GetCompressionLevel() > 0 && mess.GetCompressionLevel() == 0)
545
546 if (mess.GetCompressionLevel() > 0)
547 const_cast<TMessage&>(mess).Compress();
548
549 char *mbuf = mess.Buffer();
550 Int_t mlen = mess.Length();
551 if (mess.CompBuffer()) {
552 mbuf = mess.CompBuffer();
553 mlen = mess.CompLength();
554 }
555
557 Int_t nsent;
558 if ((nsent = gSystem->SendRaw(fSocket, mbuf, mlen, 0)) <= 0) {
559 if (nsent == -5) {
560 // Connection reset by peer or broken
562 }
563 return nsent;
564 }
565
566 fBytesSent += nsent;
568
569 // If acknowledgement is desired, wait for it
570 if (mess.What() & kMESS_ACK) {
573 char buf[2];
574 Int_t n = 0;
575 if ((n = gSystem->RecvRaw(fSocket, buf, sizeof(buf), 0)) < 0) {
576 if (n == -5) {
577 // Connection reset by peer or broken
579 } else
580 n = -1;
581 return n;
582 }
583 if (strncmp(buf, "ok", 2)) {
584 Error("Send", "bad acknowledgement");
585 return -1;
586 }
587 fBytesRecv += 2;
588 fgBytesRecv += 2;
589 }
590
591 Touch(); // update usage timestamp
592
593 return nsent - sizeof(UInt_t); //length - length header
594}
595
596////////////////////////////////////////////////////////////////////////////////
597/// Send an object. Returns the number of bytes sent and -1 in case of error.
598/// In case the "kind" has been or'ed with kMESS_ACK, the call will only
599/// return after having received an acknowledgement, making the sending
600/// synchronous.
601
603{
604 //stream object to message buffer
605 TMessage mess(kind);
606 mess.WriteObject(obj);
607
608 //now sending the object itself
609 Int_t nsent;
610 if ((nsent = Send(mess)) < 0)
611 return -1;
612
613 return nsent;
614}
615
616////////////////////////////////////////////////////////////////////////////////
617/// Send a raw buffer of specified length. Using option kOob one can send
618/// OOB data. Returns the number of bytes sent or -1 in case of error.
619/// Returns -4 in case of kNoBlock and errno == EWOULDBLOCK.
620/// Returns -5 if pipe broken or reset by peer (EPIPE || ECONNRESET).
621
623{
625
626 if (!IsValid()) return -1;
627
629 Int_t nsent;
630 if ((nsent = gSystem->SendRaw(fSocket, buffer, length, (int) opt)) <= 0) {
631 if (nsent == -5) {
632 // Connection reset or broken: close
634 }
635 return nsent;
636 }
637
638 fBytesSent += nsent;
640
641 Touch(); // update usage timestamp
642
643 return nsent;
644}
645
646////////////////////////////////////////////////////////////////////////////////
647/// Check if TStreamerInfo must be sent. The list of TStreamerInfo of classes
648/// in the object in the message is in the fInfos list of the message.
649/// We send only the TStreamerInfos not yet sent on this socket.
650
652{
653 if (mess.fInfos && mess.fInfos->GetEntries()) {
654 TIter next(mess.fInfos);
656 TList *minilist = 0;
657 while ((info = (TStreamerInfo*)next())) {
658 Int_t uid = info->GetNumber();
659 if (fBitsInfo.TestBitNumber(uid))
660 continue; //TStreamerInfo had already been sent
662 if (!minilist)
663 minilist = new TList();
664 if (gDebug > 0)
665 Info("SendStreamerInfos", "sending TStreamerInfo: %s, version = %d",
666 info->GetName(),info->GetClassVersion());
667 minilist->Add(info);
668 }
669 if (minilist) {
671 messinfo.WriteObject(minilist);
672 delete minilist;
673 if (messinfo.fInfos)
674 messinfo.fInfos->Clear();
675 if (Send(messinfo) < 0)
676 Warning("SendStreamerInfos", "problems sending TStreamerInfo's ...");
677 }
678 }
679}
680
681////////////////////////////////////////////////////////////////////////////////
682/// Check if TProcessIDs must be sent. The list of TProcessIDs
683/// in the object in the message is found by looking in the TMessage bits.
684/// We send only the TProcessIDs not yet send on this socket.
685
687{
688 if (mess.TestBitNumber(0)) {
690 Int_t npids = pids->GetEntries();
691 TProcessID *pid;
692 TList *minilist = 0;
693 for (Int_t ipid = 0; ipid < npids; ipid++) {
694 pid = (TProcessID*)pids->At(ipid);
695 if (!pid || !mess.TestBitNumber(pid->GetUniqueID()+1))
696 continue;
697 //check if a pid with this title has already been sent through the socket
698 //if not add it to the fUUIDs list
699 if (!fUUIDs) {
700 fUUIDs = new TList();
702 } else {
703 if (fUUIDs->FindObject(pid->GetTitle()))
704 continue;
705 }
706 fUUIDs->Add(new TObjString(pid->GetTitle()));
707 if (!minilist)
708 minilist = new TList();
709 if (gDebug > 0)
710 Info("SendProcessIDs", "sending TProcessID: %s", pid->GetTitle());
711 minilist->Add(pid);
712 }
713 if (minilist) {
715 messpid.WriteObject(minilist);
716 delete minilist;
717 if (Send(messpid) < 0)
718 Warning("SendProcessIDs", "problems sending TProcessID's ...");
719 }
720 }
721}
722
723////////////////////////////////////////////////////////////////////////////////
724/// Receive a character string message of maximum max length. The expected
725/// message must be of type kMESS_STRING. Returns length of received string
726/// (can be 0 if otherside of connection is closed) or -1 in case of error
727/// or -4 in case a non-blocking socket would block (i.e. there is nothing
728/// to be read).
729
730Int_t TSocket::Recv(char *str, Int_t max)
731{
732 Int_t n, kind;
733
735 if ((n = Recv(str, max, kind)) <= 0) {
736 if (n == -5) {
738 n = -1;
739 }
740 return n;
741 }
742
743 if (kind != kMESS_STRING) {
744 Error("Recv", "got message of wrong kind (expected %d, got %d)",
745 kMESS_STRING, kind);
746 return -1;
747 }
748
749 return n;
750}
751
752////////////////////////////////////////////////////////////////////////////////
753/// Receive a character string message of maximum max length. Returns in
754/// kind the message type. Returns length of received string+4 (can be 0 if
755/// other side of connection is closed) or -1 in case of error or -4 in
756/// case a non-blocking socket would block (i.e. there is nothing to be read).
757
758Int_t TSocket::Recv(char *str, Int_t max, Int_t &kind)
759{
760 Int_t n;
761 TMessage *mess;
762
764 if ((n = Recv(mess)) <= 0) {
765 if (n == -5) {
767 n = -1;
768 }
769 return n;
770 }
771
772 kind = mess->What();
773 if (str) {
774 if (mess->BufferSize() > (Int_t)sizeof(Int_t)) // if mess contains more than kind
775 mess->ReadString(str, max);
776 else
777 str[0] = 0;
778 }
779
780 delete mess;
781
782 return n; // number of bytes read (len of str + sizeof(kind)
783}
784
785////////////////////////////////////////////////////////////////////////////////
786/// Receives a status and a message type. Returns length of received
787/// integers, 2*sizeof(Int_t) (can be 0 if other side of connection
788/// is closed) or -1 in case of error or -4 in case a non-blocking
789/// socket would block (i.e. there is nothing to be read).
790
792{
793 Int_t n;
794 TMessage *mess;
795
797 if ((n = Recv(mess)) <= 0) {
798 if (n == -5) {
800 n = -1;
801 }
802 return n;
803 }
804
805 kind = mess->What();
806 (*mess) >> status;
807
808 delete mess;
809
810 return n; // number of bytes read (2 * sizeof(Int_t)
811}
812
813////////////////////////////////////////////////////////////////////////////////
814/// Receive a TMessage object. The user must delete the TMessage object.
815/// Returns length of message in bytes (can be 0 if other side of connection
816/// is closed) or -1 in case of error or -4 in case a non-blocking socket
817/// would block (i.e. there is nothing to be read) or -5 if pipe broken
818/// or reset by peer (EPIPE || ECONNRESET). In those case mess == 0.
819
821{
823
824 if (!IsValid()) {
825 mess = 0;
826 return -1;
827 }
828
831 Int_t n;
832 UInt_t len;
833 if ((n = gSystem->RecvRaw(fSocket, &len, sizeof(UInt_t), 0)) <= 0) {
834 if (n == 0 || n == -5) {
835 // Connection closed, reset or broken
837 }
838 mess = 0;
839 return n;
840 }
841 len = net2host(len); //from network to host byte order
842
843 if (len > (std::numeric_limits<decltype(len)>::max() - sizeof(decltype(len)))) {
844 Error("Recv", "Buffer length is %u and %u+sizeof(UInt_t) cannot be represented as an UInt_t.", len, len);
845 return -1;
846 }
847
849 char *buf = new char[len+sizeof(UInt_t)];
850 if ((n = gSystem->RecvRaw(fSocket, buf+sizeof(UInt_t), len, 0)) <= 0) {
851 if (n == 0 || n == -5) {
852 // Connection closed, reset or broken
854 }
855 delete [] buf;
856 mess = 0;
857 return n;
858 }
859
860 fBytesRecv += n + sizeof(UInt_t);
861 fgBytesRecv += n + sizeof(UInt_t);
862
863 mess = new TMessage(buf, len+sizeof(UInt_t));
864
865 // receive any streamer infos
867 goto oncemore;
868
869 // receive any process ids
870 if (RecvProcessIDs(mess))
871 goto oncemore;
872
873 if (mess->What() & kMESS_ACK) {
875 char ok[2] = { 'o', 'k' };
876 Int_t n2 = 0;
877 if ((n2 = gSystem->SendRaw(fSocket, ok, sizeof(ok), 0)) < 0) {
878 if (n2 == -5) {
879 // Connection reset or broken
881 }
882 delete mess;
883 mess = 0;
884 return n2;
885 }
886 mess->SetWhat(mess->What() & ~kMESS_ACK);
887
888 fBytesSent += 2;
889 fgBytesSent += 2;
890 }
891
892 Touch(); // update usage timestamp
893
894 return n;
895}
896
897////////////////////////////////////////////////////////////////////////////////
898/// Receive a raw buffer of specified length bytes. Using option kPeek
899/// one can peek at incoming data. Returns number of received bytes.
900/// Returns -1 in case of error. In case of opt == kOob: -2 means
901/// EWOULDBLOCK and -3 EINVAL. In case of non-blocking mode (kNoBlock)
902/// -4 means EWOULDBLOCK. Returns -5 if pipe broken or reset by
903/// peer (EPIPE || ECONNRESET).
904
906{
908
909 if (!IsValid()) return -1;
910 if (length == 0) return 0;
911
913 Int_t n;
914 if ((n = gSystem->RecvRaw(fSocket, buffer, length, (int) opt)) <= 0) {
915 if (n == 0 || n == -5) {
916 // Connection closed, reset or broken
918 }
919 return n;
920 }
921
922 fBytesRecv += n;
923 fgBytesRecv += n;
924
925 Touch(); // update usage timestamp
926
927 return n;
928}
929
930////////////////////////////////////////////////////////////////////////////////
931/// Receive a message containing streamer infos. In case the message contains
932/// streamer infos they are imported, the message will be deleted and the
933/// method returns kTRUE.
934
936{
937 if (mess->What() == kMESS_STREAMERINFO) {
938 TList *list = (TList*)mess->ReadObject(TList::Class());
939 TIter next(list);
941 TObjLink *lnk = list->FirstLink();
942 // First call BuildCheck for regular class
943 while (lnk) {
944 info = (TStreamerInfo*)lnk->GetObject();
945 TObject *element = info->GetElements()->UncheckedAt(0);
946 Bool_t isstl = element && strcmp("This",element->GetName())==0;
947 if (!isstl) {
948 info->BuildCheck();
949 if (gDebug > 0)
950 Info("RecvStreamerInfos", "importing TStreamerInfo: %s, version = %d",
951 info->GetName(), info->GetClassVersion());
952 }
953 lnk = lnk->Next();
954 }
955 // Then call BuildCheck for stl class
956 lnk = list->FirstLink();
957 while (lnk) {
958 info = (TStreamerInfo*)lnk->GetObject();
959 TObject *element = info->GetElements()->UncheckedAt(0);
960 Bool_t isstl = element && strcmp("This",element->GetName())==0;
961 if (isstl) {
962 info->BuildCheck();
963 if (gDebug > 0)
964 Info("RecvStreamerInfos", "importing TStreamerInfo: %s, version = %d",
965 info->GetName(), info->GetClassVersion());
966 }
967 lnk = lnk->Next();
968 }
969 delete list;
970 delete mess;
971
972 return kTRUE;
973 }
974 return kFALSE;
975}
976
977////////////////////////////////////////////////////////////////////////////////
978/// Receive a message containing process ids. In case the message contains
979/// process ids they are imported, the message will be deleted and the
980/// method returns kTRUE.
981
983{
984 if (mess->What() == kMESS_PROCESSID) {
985 TList *list = (TList*)mess->ReadObject(TList::Class());
986 TIter next(list);
987 TProcessID *pid;
988 while ((pid = (TProcessID*)next())) {
989 // check that a similar pid is not already registered in fgPIDs
992 TProcessID *p;
993 while ((p = (TProcessID*)nextpid())) {
994 if (!strcmp(p->GetTitle(), pid->GetTitle())) {
995 delete pid;
996 pid = 0;
997 break;
998 }
999 }
1000 if (pid) {
1001 if (gDebug > 0)
1002 Info("RecvProcessIDs", "importing TProcessID: %s", pid->GetTitle());
1003 pid->IncrementCount();
1004 pidslist->Add(pid);
1005 Int_t ind = pidslist->IndexOf(pid);
1006 pid->SetUniqueID((UInt_t)ind);
1007 }
1008 }
1009 delete list;
1010 delete mess;
1011
1012 return kTRUE;
1013 }
1014 return kFALSE;
1015}
1016
1017////////////////////////////////////////////////////////////////////////////////
1018/// Set socket options.
1019
1021{
1022 if (!IsValid()) return -1;
1023
1024 return gSystem->SetSockOpt(fSocket, opt, val);
1025}
1026
1027////////////////////////////////////////////////////////////////////////////////
1028/// Get socket options. Returns -1 in case of error.
1029
1031{
1032 if (!IsValid()) return -1;
1033
1034 return gSystem->GetSockOpt(fSocket, opt, &val);
1035}
1036
1037////////////////////////////////////////////////////////////////////////////////
1038/// Returns error code. Meaning depends on context where it is called.
1039/// If no error condition returns 0 else a value < 0.
1040/// For example see TServerSocket ctor.
1041
1043{
1044 if (!IsValid())
1045 return fSocket;
1046
1047 return 0;
1048}
1049
1050////////////////////////////////////////////////////////////////////////////////
1051/// See comments for function SetCompressionSettings
1052
1063
1064////////////////////////////////////////////////////////////////////////////////
1065/// See comments for function SetCompressionSettings
1066
1068{
1069 if (level < 0) level = 0;
1070 if (level > 99) level = 99;
1071 if (fCompress < 0) {
1072 // if the algorithm is not defined yet use 0 as a default
1073 fCompress = level;
1074 } else {
1075 int algorithm = fCompress / 100;
1077 fCompress = 100 * algorithm + level;
1078 }
1079}
1080
1081////////////////////////////////////////////////////////////////////////////////
1082/// Used to specify the compression level and algorithm:
1083/// settings = 100 * algorithm + level
1084///
1085/// level = 0, objects written to this file will not be compressed.
1086/// level = 1, minimal compression level but fast.
1087/// ....
1088/// level = 9, maximal compression level but slower and might use more memory.
1089/// (For the currently supported algorithms, the maximum level is 9)
1090/// If compress is negative it indicates the compression level is not set yet.
1091///
1092/// The enumeration ROOT::RCompressionSetting::EAlgorithm associates each
1093/// algorithm with a number. There is a utility function to help
1094/// to set the value of the argument. For example,
1095/// ROOT::CompressionSettings(ROOT::kLZMA, 1)
1096/// will build an integer which will set the compression to use
1097/// the LZMA algorithm and compression level 1. These are defined
1098/// in the header file Compression.h.
1099///
1100/// Note that the compression settings may be changed at any time.
1101/// The new compression settings will only apply to branches created
1102/// or attached after the setting is changed and other objects written
1103/// after the setting is changed.
1104
1109
1110////////////////////////////////////////////////////////////////////////////////
1111/// Authenticated the socket with specified user.
1112
1114{
1115 Bool_t rc = kFALSE;
1116
1117 // Parse protocol name, for PROOF, send message with server role
1119 if (sproto.Contains("sockd")) {
1120 fServType = kSOCKD;
1121 } else if (sproto.Contains("rootd")) {
1122 fServType = kROOTD;
1123 } else if (sproto.Contains("proofd")) {
1125 // Parse options
1126 TString opt(TUrl(fUrl).GetOptions());
1127 //First letter in Opt describes type of proofserv to invoke
1128 if (!strncasecmp(opt, "S", 1)) {
1129 if (Send("slave") < 0) return rc;
1130 } else if (!strncasecmp(opt, "M", 1)) {
1131 if (Send("master") < 0) return rc;
1132 } else {
1133 Warning("Authenticate",
1134 "called by TSlave: unknown option '%c' %s",
1135 opt[0], " - assuming Slave");
1136 if (Send("slave") < 0) return rc;
1137 }
1138 }
1139 if (gDebug > 2)
1140 Info("Authenticate","Local protocol: %s",sproto.Data());
1141
1142 // Get server protocol level
1143 Int_t kind = kROOTD_PROTOCOL;
1144 // Warning: for backward compatibility reasons here we have to
1145 // send exactly 4 bytes: for fgClientClientProtocol > 99
1146 // the space in the format must be dropped
1147 if (fRemoteProtocol == -1) {
1148 if (Send(Form(" %d", fgClientProtocol), kROOTD_PROTOCOL) < 0) {
1149 return rc;
1150 }
1151 if (Recv(fRemoteProtocol, kind) < 0) {
1152 return rc;
1153 }
1154 //
1155 // If we are talking to an old rootd server we get a fatal
1156 // error here and we need to reopen the connection,
1157 // communicating first the size of the parallel socket
1158 if (kind == kROOTD_ERR) {
1159 fRemoteProtocol = 9;
1160 return kFALSE;
1161 }
1162 }
1163
1164 // Find out whether authentication is required
1166 if (fRemoteProtocol > 1000) {
1167 // Authentication not required by the remote server
1168 runauth = kFALSE;
1169 fRemoteProtocol %= 1000;
1170 }
1171
1172 // If authentication is required, we need to find out which library
1173 // has to be loaded (preparation for near future, 9/7/05)
1175 if (runauth) {
1176
1177 // Default (future)
1178 TString alib = "Xrd";
1179 if (fRemoteProtocol < 100) {
1180 // Standard Authentication lib
1181 alib = "Root";
1182 }
1183
1184 // Load the plugin
1185 TPluginHandler *h =
1186 gROOT->GetPluginManager()->FindHandler("TVirtualAuth", alib);
1187 if (!h || h->LoadPlugin() != 0) {
1188 Error("Authenticate",
1189 "could not load properly %s authentication plugin", alib.Data());
1190 return rc;
1191 }
1192
1193 // Get an instance of the interface class
1194 TVirtualAuth *auth = (TVirtualAuth *)(h->ExecPlugin(0));
1195 if (!auth) {
1196 Error("Authenticate", "could not instantiate the interface class");
1197 return rc;
1198 }
1199 if (gDebug > 1)
1200 Info("Authenticate", "class for '%s' authentication loaded", alib.Data());
1201
1202 Option_t *opts = (gROOT->IsProofServ()) ? "P" : "";
1203 if (!(auth->Authenticate(this, host, user, opts))) {
1204 Error("Authenticate",
1205 "authentication attempt failed for %s@%s", user, host.Data());
1206 } else {
1207 rc = kTRUE;
1208 }
1209 } else {
1210
1211 // Communicate who we are and our target user
1213 if (u) {
1214 if (Send(Form("%s %s", u->fUser.Data(), user), kROOTD_USER) < 0)
1215 Warning("Authenticate", "problem sending kROOTD_USER (%s,%s)", u->fUser.Data(), user);
1216 delete u;
1217 } else
1218 if (Send(Form("-1 %s", user), kROOTD_USER) < 0)
1219 Warning("Authenticate", "problem sending kROOTD_USER (-1,%s)", user);
1220
1221 rc = kFALSE;
1222
1223 // Receive confirmation that everything went well
1224 Int_t stat;
1225 if (Recv(stat, kind) > 0) {
1226
1227 if (kind == kROOTD_ERR) {
1228 if (gDebug > 0)
1229 TSocket::NetError("TSocket::Authenticate", stat);
1230 } else if (kind == kROOTD_AUTH) {
1231
1232 // Authentication was not required: create inactive
1233 // security context for consistency
1234 fSecContext = new TSecContext(user, host, 0, -4, 0, 0);
1235 if (gDebug > 3)
1236 Info("Authenticate", "no authentication required remotely");
1237
1238 // Set return flag;
1239 rc = 1;
1240 } else {
1241 if (gDebug > 0)
1242 Info("Authenticate", "expected message type %d, received %d",
1243 kROOTD_AUTH, kind);
1244 }
1245 } else {
1246 if (gDebug > 0)
1247 Info("Authenticate", "error receiving message");
1248 }
1249
1250 }
1251
1252 return rc;
1253}
1254
1255////////////////////////////////////////////////////////////////////////////////
1256/// Creates a socket or a parallel socket and authenticates to the
1257/// remote server.
1258///
1259/// url: [[proto][p][auth]://][user@]host[:port][/service][?options]
1260///
1261/// where proto = "sockd", "rootd", "proofd"
1262/// indicates the type of remote server;
1263/// if missing "sockd" is assumed ("sockd" indicates
1264/// any remote server session using TServerSocket)
1265/// [p] = for parallel sockets (forced internally for
1266/// rootd; ignored for proofd)
1267/// [auth] = "up" or "k" to force UsrPwd or Krb5 authentication
1268/// [port] = is the remote port number
1269/// [service] = service name used to determine the port
1270/// (for backward compatibility, specification of
1271/// port as priority)
1272/// options = "m" or "s", when proto=proofd indicates whether
1273/// we are master or slave (used internally by
1274/// TSlave)
1275///
1276/// An already opened connection can be used by passing its socket
1277/// in opensock.
1278///
1279/// If 'err' is defined, '*err' on return from a failed call contains an error
1280/// code (see NetErrors.h).
1281///
1282/// Example:
1283///
1284/// TSocket::CreateAuthSocket("pk://qwerty@machine.fq.dn:5052",3)
1285///
1286/// creates an authenticated parallel socket of size 3 to a sockd
1287/// server running on remote machine machine.fq.dn on port 5052;
1288/// authentication will attempt protocol Kerberos first.
1289///
1290/// NB: may hang if the remote server is not of the correct type;
1291/// at present TSocket has no way to find out the type of the
1292/// remote server automatically
1293///
1294/// Returns pointer to an authenticated socket or 0 if creation or
1295/// authentication is unsuccessful.
1296
1298 TSocket *opensock, Int_t *err)
1299{
1301
1302 // Url to be passed to chosen constructor
1303 TString eurl(url);
1304
1305 // Parse protocol, if any
1307 TString proto(TUrl(url).GetProtocol());
1309
1310 // Get rid of authentication suffix
1311 TString asfx = "";
1312 if (proto.EndsWith("up") || proto.EndsWith("ug")) {
1313 asfx = proto;
1314 asfx.Remove(0,proto.Length()-2);
1315 proto.Resize(proto.Length()-2);
1316 } else if (proto.EndsWith("s") || proto.EndsWith("k") ||
1317 proto.EndsWith("g") || proto.EndsWith("h")) {
1318 asfx = proto;
1319 asfx.Remove(0,proto.Length()-1);
1320 proto.Resize(proto.Length()-1);
1321 }
1322
1323 // Find out if parallel (ignore if proofd, force if rootd)
1324 if (((proto.EndsWith("p") || size > 1) &&
1325 !proto.BeginsWith("proof")) ||
1326 proto.BeginsWith("root") ) {
1327 parallel = kTRUE;
1328 if (proto.EndsWith("p"))
1329 proto.Resize(proto.Length()-1);
1330 }
1331
1332 // Force "sockd" if the rest is not recognized
1333 if (!proto.BeginsWith("sock") && !proto.BeginsWith("proof") &&
1334 !proto.BeginsWith("root"))
1335 proto = "sockd";
1336
1337 // Substitute this for original proto in eurl
1338 protosave += "://";
1339 proto += asfx;
1340 proto += "://";
1341 eurl.ReplaceAll(protosave,proto);
1342
1343 // Create the socket now
1344
1345 TSocket *sock = 0;
1346 if (!parallel) {
1347
1348 // Simple socket
1349 if (opensock && opensock->IsValid())
1350 sock = opensock;
1351 else
1352 sock = new TSocket(eurl, TUrl(url).GetPort(), tcpwindowsize);
1353
1354 // Authenticate now
1355 if (sock && sock->IsValid()) {
1356 if (!sock->Authenticate(TUrl(url).GetUser())) {
1357 // Nothing to do except setting the error code (if required) and sock to NULL
1358 if (err) {
1359 *err = (Int_t)kErrAuthNotOK;
1361 }
1362 sock->Close();
1363 delete sock;
1364 sock = 0;
1365 }
1366 }
1367
1368 } else {
1369
1370 // Tell TPSocket that we want authentication, which has to
1371 // be done using the original socket before creation of set
1372 // of parallel sockets
1373 if (eurl.Contains("?"))
1374 eurl.Resize(eurl.Index("?"));
1375 eurl += "?A";
1376
1377 // Parallel socket
1378 if (opensock && opensock->IsValid())
1379 sock = new TPSocket(eurl, TUrl(url).GetPort(), size, opensock);
1380 else
1381 sock = new TPSocket(eurl, TUrl(url).GetPort(), size, tcpwindowsize);
1382
1383 // Cleanup if failure ...
1384 if (sock && !sock->IsAuthenticated()) {
1385 // Nothing to do except setting the error code (if required) and sock to NULL
1386 if (err) {
1387 *err = (Int_t)kErrAuthNotOK;
1389 }
1390 if (sock->IsValid())
1391 // And except when the sock is valid; this typically
1392 // happens when talking to a old server, because the
1393 // the parallel socket system is open before authentication
1394 delete sock;
1395 sock = 0;
1396 }
1397 }
1398
1399 return sock;
1400}
1401
1402////////////////////////////////////////////////////////////////////////////////
1403/// Creates a socket or a parallel socket and authenticates to the
1404/// remote server specified in 'url' on remote 'port' as 'user'.
1405///
1406/// url: [[proto][p][auth]://]host[/?options]
1407///
1408/// where proto = "sockd", "rootd", "proofd"
1409/// indicates the type of remote server
1410/// if missing "sockd" is assumed ("sockd" indicates
1411/// any remote server session using TServerSocket)
1412/// [p] = for parallel sockets (forced internally for
1413/// rootd)
1414/// [auth] = "up" or "k" to force UsrPwd or Krb5 authentication
1415/// [options] = "m" or "s", when proto=proofd indicates whether
1416/// we are master or slave (used internally by TSlave)
1417///
1418/// An already opened connection can be used by passing its socket
1419/// in opensock.
1420///
1421/// If 'err' is defined, '*err' on return from a failed call contains an error
1422/// code (see NetErrors.h).
1423///
1424/// Example:
1425///
1426/// TSocket::CreateAuthSocket("qwerty","pk://machine.fq.dn:5052",3)
1427///
1428/// creates an authenticated parallel socket of size 3 to a sockd
1429/// server running on remote machine machine.fq.dn on port 5052;
1430/// authentication will attempt protocol Kerberos first.
1431///
1432/// NB: may hang if the remote server is not of the correct type;
1433/// at present TSocket has no way to find out the type of the
1434/// remote server automatically
1435///
1436/// Returns pointer to an authenticated socket or 0 if creation or
1437/// authentication is unsuccessful.
1438
1439TSocket *TSocket::CreateAuthSocket(const char *user, const char *url,
1441 TSocket *opensock, Int_t *err)
1442{
1444
1445 // Extended url to be passed to base call
1446 TString eurl;
1447
1448 // Add protocol, if any
1449 if (TString(TUrl(url).GetProtocol()).Length() > 0) {
1450 eurl += TString(TUrl(url).GetProtocol());
1451 eurl += TString("://");
1452 }
1453 // Add user, if any
1454 if (!user || strlen(user) > 0) {
1455 eurl += TString(user);
1456 eurl += TString("@");
1457 }
1458 // Add host
1459 eurl += TString(TUrl(url).GetHost());
1460 // Add port
1461 eurl += TString(":");
1462 eurl += (port > 0 ? port : 0);
1463 // Add options, if any
1464 if (TString(TUrl(url).GetOptions()).Length() > 0) {
1465 eurl += TString("/?");
1466 eurl += TString(TUrl(url).GetOptions());
1467 }
1468
1469 // Create the socket and return it
1471}
1472
1473////////////////////////////////////////////////////////////////////////////////
1474/// Static method returning supported client protocol.
1475
1480
1481////////////////////////////////////////////////////////////////////////////////
1482/// Print error string depending on error code.
1483
1484void TSocket::NetError(const char *where, Int_t err)
1485{
1486 // Make sure it is in range
1487 err = (err < kErrError) ? ((err > -1) ? err : 0) : kErrError;
1488
1489 if (gDebug > 0)
1490 ::Error(where, "%s", gRootdErrStr[err]);
1491}
1492
1493////////////////////////////////////////////////////////////////////////////////
1494/// Get total number of bytes sent via all sockets.
1495
1500
1501////////////////////////////////////////////////////////////////////////////////
1502/// Get total number of bytes received via all sockets.
1503
UShort_t net2host(UShort_t x)
Definition Bytes.h:575
@ kMESS_STRING
@ kROOTD_USER
@ kMESS_ACK
@ kROOTD_PROTOCOL
@ kROOTD_AUTH
@ kMESS_PROCESSID
@ kROOTD_ERR
@ kMESS_STREAMERINFO
R__EXTERN const char * gRootdErrStr[]
Definition NetErrors.h:72
@ kErrAuthNotOK
Definition NetErrors.h:51
@ kErrConnectionRefused
Definition NetErrors.h:50
@ kErrError
Definition NetErrors.h:69
#define SafeDelete(p)
Definition RConfig.hxx:538
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
unsigned long long ULong64_t
Definition RtypesCore.h:70
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.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
winID h TVirtualViewer3D TVirtualGLPainter p
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
Int_t gDebug
Definition TROOT.cxx:622
#define gROOT
Definition TROOT.h:414
TVirtualMutex * gSocketAuthMutex
Definition TSocket.cxx:65
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
ESockOptions
Definition TSystem.h:229
ESendRecvOptions
Definition TSystem.h:242
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define R__LOCKGUARD2(mutex)
const char * proto
Definition civetweb.c:17535
Bool_t TestBitNumber(UInt_t bitnumber) const
Definition TBits.h:222
void SetBitNumber(UInt_t bitnumber, Bool_t value=kTRUE)
Definition TBits.h:206
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
This class represents an Internet Protocol (IP) address.
Int_t GetPort() const
const char * GetHostName() const
A doubly linked list.
Definition TList.h:38
static TClass * Class()
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:576
void Add(TObject *obj) override
Definition TList.h:81
Int_t Compress()
Compress the message.
Definition TMessage.cxx:319
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:174
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
TString fName
Definition TNamed.h:32
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:150
An array of TObjects.
Definition TObjArray.h:31
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:205
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition TObject.cxx:475
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
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:875
void ResetBit(UInt_t f)
Definition TObject.h:204
This class implements parallel server sockets.
Definition TPSocket.h:33
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition TProcessID.h:74
Int_t IncrementCount()
Increase the reference count to this object.
static TObjArray * GetPIDs()
static: returns array of TProcessIDs
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
TVirtualMutex * fLastUsageMtx
Definition TSocket.h:75
void SetCompressionLevel(Int_t level=ROOT::RCompressionSetting::ELevel::kUseMin)
See comments for function SetCompressionSettings.
Definition TSocket.cxx:1067
void SendStreamerInfos(const TMessage &mess)
Check if TStreamerInfo must be sent.
Definition TSocket.cxx:651
@ kInvalidStillInList
Definition TSocket.h:57
@ kInvalid
Definition TSocket.h:56
TString fUrl
Definition TSocket.h:71
void SetCompressionAlgorithm(Int_t algorithm=ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
See comments for function SetCompressionSettings.
Definition TSocket.cxx:1053
TSocket()
Definition TSocket.h:83
static ULong64_t GetSocketBytesSent()
Get total number of bytes sent via all sockets.
Definition TSocket.cxx:1496
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
TList * fUUIDs
Definition TSocket.h:73
static Int_t GetClientProtocol()
Static method returning supported client protocol.
Definition TSocket.cxx:1476
TBits fBitsInfo
Definition TSocket.h:72
Bool_t Authenticate(const char *user)
Authenticated the socket with specified user.
Definition TSocket.cxx:1113
TInetAddress fLocalAddress
Definition TSocket.h:63
static ULong64_t fgBytesRecv
Definition TSocket.h:78
@ kBrokenConn
Definition TSocket.h:49
virtual void Close(Option_t *opt="")
Close the socket.
Definition TSocket.cxx:391
void MarkBrokenConnection()
Close the socket and mark as due to a broken connection.
Definition TSocket.cxx:373
void Touch()
Definition TSocket.h:157
Bool_t RecvProcessIDs(TMessage *mess)
Receive a message containing process ids.
Definition TSocket.cxx:982
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
static ULong64_t fgBytesSent
Definition TSocket.h:79
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
static Int_t fgClientProtocol
Definition TSocket.h:81
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
virtual Int_t Select(Int_t interest=kRead, Long_t timeout=-1)
Waits for this socket to change status.
Definition TSocket.cxx:445
virtual Int_t GetLocalPort()
Return the local port # to which the socket is bound.
Definition TSocket.cxx:425
Int_t fTcpWindowSize
Definition TSocket.h:70
Option_t * GetOption() const override
Definition TSocket.h:98
@ kSOCKD
Definition TSocket.h:52
@ kROOTD
Definition TSocket.h:52
@ kPROOFD
Definition TSocket.h:52
static TSocket * CreateAuthSocket(const char *user, const char *host, Int_t port, Int_t size=0, Int_t tcpwindowsize=-1, TSocket *s=nullptr, Int_t *err=nullptr)
Creates a socket or a parallel socket and authenticates to the remote server specified in 'url' on re...
Definition TSocket.cxx:1439
static void NetError(const char *where, Int_t error)
Print error string depending on error code.
Definition TSocket.cxx:1484
Int_t GetPort() const
Definition TSocket.h:115
EServiceType fServType
Definition TSocket.h:68
virtual Int_t SendObject(const TObject *obj, Int_t kind=kMESS_OBJECT)
Send an object.
Definition TSocket.cxx:602
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 Bool_t IsAuthenticated() const
Definition TSocket.h:131
static ULong64_t GetSocketBytesRecv()
Get total number of bytes received via all sockets.
Definition TSocket.cxx:1504
Describes a persistent version of a class.
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
const char * Data() const
Definition TString.h:376
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2356
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
virtual int GetServiceByName(const char *service)
Get port # of internet service.
Definition TSystem.cxx:2330
virtual TInetAddress GetSockName(int sock)
Get Internet Protocol (IP) address of host and port #.
Definition TSystem.cxx:2321
static void ResetErrno()
Static function resetting system error number.
Definition TSystem.cxx:284
virtual char * GetServiceByPort(int port)
Get name of internet service.
Definition TSystem.cxx:2339
virtual int SetSockOpt(int sock, int kind, int val)
Set socket option.
Definition TSystem.cxx:2448
virtual TInetAddress GetPeerName(int sock)
Get Internet Protocol (IP) address of remote host and port #.
Definition TSystem.cxx:2312
virtual int OpenConnection(const char *server, int port, int tcpwindowsize=-1, const char *protocol="tcp")
Open a connection to another host.
Definition TSystem.cxx:2348
virtual int GetSockOpt(int sock, int kind, int *val)
Get socket option.
Definition TSystem.cxx:2457
virtual int RecvRaw(int sock, void *buffer, int length, int flag)
Receive exactly length bytes into buffer.
Definition TSystem.cxx:2411
virtual Int_t Select(TList *active, Long_t timeout)
Select on active file descriptors (called by TMonitor).
Definition TSystem.cxx:445
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
Definition TSystem.cxx:2303
virtual int SendRaw(int sock, const void *buffer, int length, int flag)
Send exactly length bytes from buffer.
Definition TSystem.cxx:2421
virtual void CloseConnection(int sock, Bool_t force=kFALSE)
Close socket connection.
Definition TSystem.cxx:2402
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
Definition TSystem.cxx:1613
This class represents a WWW compatible URL.
Definition TUrl.h:33
const char * GetProtocol() const
Definition TUrl.h:64
Int_t GetPort() const
Definition TUrl.h:78
This class implements a mutex interface.
std::ostream & Info()
Definition hadd.cxx:171
const Int_t n
Definition legend1.C:16
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
@ kUndefined
Undefined compression algorithm (must be kept the last of the list in case a new algorithm is added).
@ kUseMin
Compression level reserved when we are not sure what to use (1 is for the fastest compression)
Definition Compression.h:72