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#include <limits>
38
39////////////////////////////////////////////////////////////////////////////////
40/// Create a parallel socket. Connect to the named service at address addr.
41/// Use tcpwindowsize to specify the size of the receive buffer, it has
42/// to be specified here to make sure the window scale option is set (for
43/// tcpwindowsize > 65KB and for platforms supporting window scaling).
44/// Returns when connection has been accepted by remote side. Use IsValid()
45/// to check the validity of the socket. Every socket is added to the TROOT
46/// sockets list which will make sure that any open sockets are properly
47/// closed on program termination.
48
55
56////////////////////////////////////////////////////////////////////////////////
57/// Create a parallel socket. Connect to the specified port # at address addr.
58/// Use tcpwindowsize to specify the size of the receive buffer, it has
59/// to be specified here to make sure the window scale option is set (for
60/// tcpwindowsize > 65KB and for platforms supporting window scaling).
61/// Returns when connection has been accepted by remote side. Use IsValid()
62/// to check the validity of the socket. Every socket is added to the TROOT
63/// sockets list which will make sure that any open sockets are properly
64/// closed on program termination.
65
72
73////////////////////////////////////////////////////////////////////////////////
74/// Create a parallel socket. Connect to named service on the remote host.
75/// Use tcpwindowsize to specify the size of the receive buffer, it has
76/// to be specified here to make sure the window scale option is set (for
77/// tcpwindowsize > 65KB and for platforms supporting window scaling).
78/// Returns when connection has been accepted by remote side. Use IsValid()
79/// to check the validity of the socket. Every socket is added to the TROOT
80/// sockets list which will make sure that any open sockets are properly
81/// closed on program termination.
82
83TPSocket::TPSocket(const char *host, const char *service, Int_t size,
85{
86 fSize = size;
88}
89
90////////////////////////////////////////////////////////////////////////////////
91/// Create a parallel socket. Connect to specified port # on the remote host.
92/// Use tcpwindowsize to specify the size of the receive buffer, it has
93/// to be specified here to make sure the window scale option is set (for
94/// tcpwindowsize > 65KB and for platforms supporting window scaling).
95/// Returns when connection has been accepted by remote side. Use IsValid()
96/// to check the validity of the socket. Every socket is added to the TROOT
97/// sockets list which will make sure that any open sockets are properly
98/// closed on program termination.
99
100TPSocket::TPSocket(const char *host, Int_t port, Int_t size,
102 : TSocket(host, port, (Int_t)(size > 1 ? -1 : tcpwindowsize))
103{
104 // set to the real value only at end (except for old servers)
105 fSize = 1;
106
107 // to control the flow
109
110 // check if we are called from CreateAuthSocket()
112 char *pauth = (char *)strstr(host, "?A");
113 if (pauth) {
114 authreq = kTRUE;
115 }
116
117 // perhaps we can use fServType here ... to be checked
118 Bool_t rootdSrv = (strstr(host,"rootd")) ? kTRUE : kFALSE;
119
120 // try authentication , if required
121 if (authreq) {
122 if (valid) {
123 if (!Authenticate(TUrl(host).GetUser())) {
124 if (rootdSrv && (fRemoteProtocol > 0 && fRemoteProtocol < 10)) {
125 // We failed because we are talking to an old
126 // server: we need to re-open the connection
127 // and communicate the size first
128 Int_t tcpw = (size > 1 ? -1 : tcpwindowsize);
129 TSocket *ns = new TSocket(host, port, tcpw);
130 if (ns->IsValid()) {
132 gROOT->GetListOfSockets()->Remove(ns);
133 fSocket = ns->GetDescriptor();
134 fSize = size;
136 }
137 if ((valid = IsValid())) {
138 if (!Authenticate(TUrl(host).GetUser())) {
140 valid = kFALSE;
141 }
142 }
143 } else {
145 valid = kFALSE;
146 }
147 }
148 }
149 // reset url to the original state
150 *pauth = '\0';
151 SetUrl(host);
152 }
153
154 // open the sockets ...
155 if (!rootdSrv || fRemoteProtocol > 9) {
156 if (valid) {
157 fSize = size;
159 }
160 }
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Create a parallel socket on a connection already opened via
165/// TSocket sock.
166/// This constructor is provided to optimize TNetFile opening when
167/// instatiated via a call to TNetXNGFile.
168/// Returns when connection has been accepted by remote side. Use IsValid()
169/// to check the validity of the socket. Every socket is added to the TROOT
170/// sockets list which will make sure that any open sockets are properly
171/// closed on program termination.
172
173TPSocket::TPSocket(const char *host, Int_t port, Int_t size, TSocket *sock)
174{
175 // To avoid uninitialization problems when Init is not called ...
176 fSockets = 0;
177 fWriteMonitor = 0;
178 fReadMonitor = 0;
179 fWriteBytesLeft = 0;
180 fReadBytesLeft = 0;
181 fWritePtr = 0;
182 fReadPtr = 0;
183
184 // set to the real value only at end (except for old servers)
185 fSize = 1;
186
187 // We need a opened connection
188 if (!sock) return;
189
190 // Now import existing socket info
191 fSocket = sock->GetDescriptor();
192 fService = sock->GetService();
193 fAddress = sock->GetInetAddress();
195 fBytesSent = sock->GetBytesSent();
196 fBytesRecv = sock->GetBytesRecv();
198 fSecContext = sock->GetSecContext();
202
203 // to control the flow
204 Bool_t valid = sock->IsValid();
205
206 // check if we are called from CreateAuthSocket()
208 char *pauth = (char *)strstr(host, "?A");
209 if (pauth) {
210 authreq = kTRUE;
211 }
212
213 // perhaps we can use fServType here ... to be checked
214 Bool_t rootdSrv = (strstr(host,"rootd")) ? kTRUE : kFALSE;
215
216 // try authentication , if required
217 if (authreq) {
218 if (valid) {
219 if (!Authenticate(TUrl(host).GetUser())) {
220 if (rootdSrv && (fRemoteProtocol > 0 && fRemoteProtocol < 10)) {
221 // We failed because we are talking to an old
222 // server: we need to re-open the connection
223 // and communicate the size first
224 Int_t tcpw = (size > 1 ? -1 : fTcpWindowSize);
225 TSocket *ns = new TSocket(host, port, tcpw);
226 if (ns->IsValid()) {
228 gROOT->GetListOfSockets()->Remove(ns);
229 fSocket = ns->GetDescriptor();
230 fSize = size;
232 }
233 if ((valid = IsValid())) {
234 if (!Authenticate(TUrl(host).GetUser())) {
236 valid = kFALSE;
237 }
238 }
239 } else {
241 valid = kFALSE;
242 }
243 }
244 }
245 // reset url to the original state
246 *pauth = '\0';
247 SetUrl(host);
248 }
249
250 // open the sockets ...
251 if (!rootdSrv || fRemoteProtocol > 9) {
252 if (valid) {
253 fSize = size;
254 Init(fTcpWindowSize, sock);
255 }
256 }
257
258 // Add to the list if everything OK
259 if (IsValid()) {
261 gROOT->GetListOfSockets()->Add(this);
262 }
263}
264
265////////////////////////////////////////////////////////////////////////////////
266/// Create a parallel socket. This ctor is called by TPServerSocket.
267
269{
271 fSize = size;
272
273 // set descriptor if simple socket (needed when created
274 // by TPServerSocket)
275 if (fSize <= 1)
277
278 // set socket options (no blocking and no delay)
280 if (fSize > 1)
282
287 fWritePtr = new char*[fSize];
288 fReadPtr = new char*[fSize];
289
290 for (int i = 0; i < fSize; i++) {
293 }
296
297 SetName(fSockets[0]->GetName());
300
301 {
303 gROOT->GetListOfSockets()->Add(this);
304 }
305}
306
307////////////////////////////////////////////////////////////////////////////////
308/// Cleanup the parallel socket.
309
311{
312 Close();
313
314 delete fWriteMonitor;
315 delete fReadMonitor;
316 delete [] fWriteBytesLeft;
317 delete [] fReadBytesLeft;
318 delete [] fWritePtr;
319 delete [] fReadPtr;
320}
321
322////////////////////////////////////////////////////////////////////////////////
323/// Close a parallel socket. If option is "force", calls shutdown(id,2) to
324/// shut down the connection. This will close the connection also
325/// for the parent of this process. Also called via the dtor (without
326/// option "force", call explicitly Close("force") if this is desired).
327
329{
330
331 if (!IsValid()) {
332 // if closing happens too early (e.g. timeout) the underlying
333 // socket may still be open
335 return;
336 }
337
338 if (fSize <= 1) {
340 } else {
341 for (int i = 0; i < fSize; i++) {
342 fSockets[i]->Close(option);
343 delete fSockets[i];
344 }
345 }
346 delete [] fSockets;
347 fSockets = 0;
348
349 {
351 gROOT->GetListOfSockets()->Remove(this);
352 }
353}
354
355////////////////////////////////////////////////////////////////////////////////
356/// Create a parallel socket to the specified host.
357
359{
360 fSockets = 0;
361 fWriteMonitor = 0;
362 fReadMonitor = 0;
363 fWriteBytesLeft = 0;
364 fReadBytesLeft = 0;
365 fWritePtr = 0;
366 fReadPtr = 0;
367
368 if ((sock && !sock->IsValid()) || !TSocket::IsValid())
369 return;
370
371 Int_t i = 0;
372
373 if (fSize <= 1) {
374 // check if single mode
375 fSize = 1;
376
377 // set socket options (no delay)
378 if (sock)
379 sock->SetOption(kNoDelay, 1);
380 else
382
383 // if yes, communicate this to server
384 // (size = 0 for backward compatibility)
385 if (sock) {
386 if (sock->Send((Int_t)0, (Int_t)0) < 0)
387 Warning("Init", "%p: problems sending (0,0)", sock);
388 } else {
389 if (TSocket::Send((Int_t)0, (Int_t)0) < 0)
390 Warning("Init", "problems sending (0,0)");
391 }
392
393 // needs to fill additional private members
394 fSockets = new TSocket*[1];
395 fSockets[0]= (TSocket *)this;
396
397 } else {
398
399 // create server that will be used to accept the parallel sockets from
400 // the remote host, use port=0 to scan for a free port
402
403 // send the local port number of the just created server socket and the
404 // number of desired parallel sockets
405 if (sock) {
406 if (sock->Send(ss.GetLocalPort(), fSize) < 0)
407 Warning("Init", "%p: problems sending size", sock);
408 } else {
409 if (TSocket::Send(ss.GetLocalPort(), fSize) < 0)
410 Warning("Init", "problems sending size");
411 }
412
413 fSockets = new TSocket*[fSize];
414
415 // establish fSize parallel socket connections between client and server
416 for (i = 0; i < fSize; i++) {
417 fSockets[i] = ss.Accept();
419 gROOT->GetListOfSockets()->Remove(fSockets[i]);
420 }
421
422 // set socket options (no blocking and no delay)
425
426 // close original socket
427 if (sock)
428 sock->Close();
429 else
431 fSocket = -1;
432 }
433
438 fWritePtr = new char*[fSize];
439 fReadPtr = new char*[fSize];
440
441 for (i = 0; i < fSize; i++) {
444 }
447}
448
449////////////////////////////////////////////////////////////////////////////////
450/// Return internet address of local host to which the socket is bound.
451/// In case of error TInetAddress::IsValid() returns kFALSE.
452
454{
455 if (fSize<= 1)
457
458 if (IsValid()) {
459 if (fLocalAddress.GetPort() == -1)
461 return fLocalAddress;
462 }
463 return TInetAddress();
464}
465
466////////////////////////////////////////////////////////////////////////////////
467/// Return socket descriptor
468
470{
471 if (fSize <= 1)
472 return TSocket::GetDescriptor();
473
474 return fSockets ? fSockets[0]->GetDescriptor() : -1;
475
476}
477
478////////////////////////////////////////////////////////////////////////////////
479/// Send a TMessage object. Returns the number of bytes in the TMessage
480/// that were sent and -1 in case of error. In case the TMessage::What
481/// has been or'ed with kMESS_ACK, the call will only return after having
482/// received an acknowledgement, making the sending process synchronous.
483/// Returns -4 in case of kNoBlock and errno == EWOULDBLOCK.
484
486{
487 if (!fSockets || fSize <= 1)
488 return TSocket::Send(mess); // only the case when called via Init()
489
490 if (!IsValid()) {
491 return -1;
492 }
493
494 if (mess.IsReading()) {
495 Error("Send", "cannot send a message used for reading");
496 return -1;
497 }
498
499 // send streamer infos in case schema evolution is enabled in the TMessage
501
502 // send the process id's so TRefs work
504
505 mess.SetLength(); //write length in first word of buffer
506
507 if (GetCompressionLevel() > 0 && mess.GetCompressionLevel() == 0)
509
510 if (mess.GetCompressionLevel() > 0)
511 const_cast<TMessage&>(mess).Compress();
512
513 char *mbuf = mess.Buffer();
514 Int_t mlen = mess.Length();
515 if (mess.CompBuffer()) {
516 mbuf = mess.CompBuffer();
517 mlen = mess.CompLength();
518 }
519
520 Int_t nsent, ulen = (Int_t) sizeof(UInt_t);
521 // send length
522 if ((nsent = SendRaw(mbuf, ulen, kDefault)) <= 0)
523 return nsent;
524
525 // send buffer (this might go in parallel)
526 if ((nsent = SendRaw(mbuf+ulen, mlen-ulen, kDefault)) <= 0)
527 return nsent;
528
529 // if acknowledgement is desired, wait for it
530 if (mess.What() & kMESS_ACK) {
531 char buf[2];
532 if (RecvRaw(buf, sizeof(buf), kDefault) < 0)
533 return -1;
534 if (strncmp(buf, "ok", 2)) {
535 Error("Send", "bad acknowledgement");
536 return -1;
537 }
538 }
539
540 return nsent; //length - length header
541}
542
543////////////////////////////////////////////////////////////////////////////////
544/// Send a raw buffer of specified length. Returns the number of bytes
545/// send and -1 in case of error.
546
548{
549 if (fSize == 1)
550 return TSocket::SendRaw(buffer,length,opt);
551
552 if (!fSockets) return -1;
553
554 // if data buffer size < 4K use only one socket
555 Int_t i, nsocks = fSize, len = length;
556 if (len < 4096)
557 nsocks = 1;
558
560 if (nsocks == 1)
562
563 if (opt != kDefault) {
564 nsocks = 1;
565 sendopt = opt;
566 }
567
568 if (nsocks == 1)
570 else
572
573 // setup pointer appropriately for transferring data equally on the
574 // parallel sockets
575 for (i = 0; i < nsocks; i++) {
577 fWritePtr[i] = (char *)buffer + (i*fWriteBytesLeft[i]);
579 }
581
582 // send the data on the parallel sockets
583 while (len > 0) {
585 for (int is = 0; is < nsocks; is++) {
586 if (s == fSockets[is]) {
587 if (fWriteBytesLeft[is] > 0) {
588 Int_t nsent;
589again:
591 if ((nsent = fSockets[is]->SendRaw(fWritePtr[is],
592 fWriteBytesLeft[is],
593 sendopt)) <= 0) {
594 if (nsent == -4) {
595 // got EAGAIN/EWOULDBLOCK error, keep trying...
596 goto again;
597 }
599 if (nsent == -5) {
600 // connection reset by peer or broken ...
602 Close();
603 }
604 return -1;
605 }
606 if (opt == kDontBlock) {
608 return nsent;
609 }
610 fWriteBytesLeft[is] -= nsent;
611 fWritePtr[is] += nsent;
612 len -= nsent;
613 }
614 }
615 }
616 }
618
619 return length;
620}
621
622////////////////////////////////////////////////////////////////////////////////
623/// Receive a TMessage object. The user must delete the TMessage object.
624/// Returns length of message in bytes (can be 0 if other side of connection
625/// is closed) or -1 in case of error or -4 in case a non-blocking socket would
626/// block (i.e. there is nothing to be read). In those case mess == 0.
627
629{
630 if (fSize <= 1)
631 return TSocket::Recv(mess);
632
633 if (!IsValid()) {
634 mess = 0;
635 return -1;
636 }
637
639 Int_t n;
640 UInt_t len;
641 if ((n = RecvRaw(&len, sizeof(UInt_t), kDefault)) <= 0) {
642 mess = 0;
643 return n;
644 }
645 len = net2host(len); //from network to host byte order
646
647 if (len > (std::numeric_limits<decltype(len)>::max() - sizeof(decltype(len)))) {
648 Error("Recv", "Buffer length is %u and %u+sizeof(UInt_t) cannot be represented as an UInt_t.", len, len);
649 return -1;
650 }
651
652 char *buf = new char[len+sizeof(UInt_t)];
653 if ((n = RecvRaw(buf+sizeof(UInt_t), len, kDefault)) <= 0) {
654 delete [] buf;
655 mess = 0;
656 return n;
657 }
658
659 mess = new TMessage(buf, len+sizeof(UInt_t));
660
661 // receive any streamer infos
663 goto oncemore;
664
665 // receive any process ids
666 if (RecvProcessIDs(mess))
667 goto oncemore;
668
669 if (mess->What() & kMESS_ACK) {
670 char ok[2] = { 'o', 'k' };
671 if (SendRaw(ok, sizeof(ok), kDefault) < 0) {
672 delete mess;
673 mess = 0;
674 return -1;
675 }
676 mess->SetWhat(mess->What() & ~kMESS_ACK);
677 }
678
679 return n;
680}
681
682////////////////////////////////////////////////////////////////////////////////
683/// Send a raw buffer of specified length. Returns the number of bytes
684/// sent or -1 in case of error.
685
687{
688 if (fSize <= 1)
689 return TSocket::RecvRaw(buffer,length,opt);
690
691 if (!fSockets) return -1;
692
693 // if data buffer size < 4K use only one socket
694 Int_t i, nsocks = fSize, len = length;
695 if (len < 4096)
696 nsocks = 1;
697
699 if (nsocks == 1)
701
702 if (opt != kDefault) {
703 nsocks = 1;
704 recvopt = opt;
705 }
706
707 if (nsocks == 1)
709 else
711
712 // setup pointer appropriately for transferring data equally on the
713 // parallel sockets
714 for (i = 0; i < nsocks; i++) {
716 fReadPtr[i] = (char *)buffer + (i*fReadBytesLeft[i]);
718 }
720
721 // start receiving data on all sockets. Receive data as and when
722 // they are available on a socket by by using select.
723 // Exit the loop as soon as all data has been received.
724 while (len > 0) {
726 for (int is = 0; is < nsocks; is++) {
727 if (s == fSockets[is]) {
728 if (fReadBytesLeft[is] > 0) {
729 Int_t nrecv;
731 if ((nrecv = fSockets[is]->RecvRaw(fReadPtr[is],
732 fReadBytesLeft[is],
733 recvopt)) <= 0) {
735 if (nrecv == -5) {
736 // connection reset by peer or broken ...
738 Close();
739 }
740 return -1;
741 }
742 if (opt == kDontBlock) {
744 return nrecv;
745 }
746 fReadBytesLeft[is] -= nrecv;
747 fReadPtr[is] += nrecv;
748 len -= nrecv;
749 }
750 }
751 }
752 }
754
755 return length;
756}
757
758////////////////////////////////////////////////////////////////////////////////
759/// Set socket options.
760
762{
763 if (fSize <= 1)
764 return TSocket::SetOption(opt,val);
765
766 Int_t ret = 0;
767 for (int i = 0; i < fSize; i++)
768 ret = fSockets[i]->SetOption(opt, val);
769 return ret;
770}
771
772////////////////////////////////////////////////////////////////////////////////
773/// Get socket options. Returns -1 in case of error.
774
776{
777 if (fSize <= 1)
778 return TSocket::GetOption(opt,val);
779
780 Int_t ret = 0;
781 for (int i = 0; i < fSize; i++)
782 ret = fSockets[i]->GetOption(opt, val);
783 return ret;
784}
785
786////////////////////////////////////////////////////////////////////////////////
787/// Returns error code. Meaning depends on context where it is called.
788/// If no error condition returns 0 else a value < 0.
789
791{
792 if (fSize <= 1)
793 return TSocket::GetErrorCode();
794
795 return fSockets[0] ? fSockets[0]->GetErrorCode() : 0;
796}
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
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
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
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:582
#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:318
TSocket * Select()
Return pointer to socket for which an event is waiting.
Definition TMonitor.cxx:321
virtual void Activate(TSocket *sock)
Activate a de-activated socket.
Definition TMonitor.cxx:249
virtual void Add(TSocket *sock, Int_t interest=kRead)
Add socket to the monitor's active list.
Definition TMonitor.cxx:167
virtual void DeActivateAll()
De-activate all activated sockets.
Definition TMonitor.cxx:301
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
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:149
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1081
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:885
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1095
void ResetBit(UInt_t f)
Definition TObject.h:203
Int_t Send(const TMessage &mess) override
Send a TMessage object.
Definition TPSocket.cxx:485
Int_t Recv(TMessage *&mess) override
Receive a TMessage object.
Definition TPSocket.cxx:628
TPSocket(TSocket *pSockets[], Int_t size)
Create a parallel socket. This ctor is called by TPServerSocket.
Definition TPSocket.cxx:268
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:328
virtual ~TPSocket()
Cleanup the parallel socket.
Definition TPSocket.cxx:310
void Init(Int_t tcpwindowsize, TSocket *sock=nullptr)
Create a parallel socket to the specified host.
Definition TPSocket.cxx:358
TMonitor * fReadMonitor
Definition TPSocket.h:40
Int_t GetErrorCode() const
Returns error code.
Definition TPSocket.cxx:790
Int_t SetOption(ESockOptions opt, Int_t val) override
Set socket options.
Definition TPSocket.cxx:761
TInetAddress GetLocalInetAddress() override
Return internet address of local host to which the socket is bound.
Definition TPSocket.cxx:453
Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault) override
Send a raw buffer of specified length.
Definition TPSocket.cxx:686
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:469
Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault) override
Send a raw buffer of specified length.
Definition TPSocket.cxx:547
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:65
Int_t fCompress
Definition TSocket.h:68
virtual Int_t SetOption(ESockOptions opt, Int_t val)
Set socket options.
Definition TSocket.cxx:1021
Int_t fSocket
Definition TSocket.h:75
Int_t GetErrorCode() const
Returns error code.
Definition TSocket.cxx:1043
UInt_t GetBytesRecv() const
Definition TSocket.h:126
void SendStreamerInfos(const TMessage &mess)
Check if TStreamerInfo must be sent.
Definition TSocket.cxx:642
const char * GetService() const
Definition TSocket.h:122
TSocket()
Definition TSocket.h:89
TString fService
Definition TSocket.h:73
Bool_t RecvStreamerInfos(TMessage *mess)
Receive a message containing streamer infos.
Definition TSocket.cxx:936
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Definition TSocket.cxx:811
Int_t GetRemoteProtocol() const
Definition TSocket.h:132
UInt_t GetBytesSent() const
Definition TSocket.h:125
Bool_t Authenticate(const char *user)
Authenticated the socket with specified user.
Definition TSocket.cxx:1114
TInetAddress fLocalAddress
Definition TSocket.h:69
Int_t GetTcpWindowSize() const
Definition TSocket.h:134
@ kBrokenConn
Definition TSocket.h:47
virtual void Close(Option_t *opt="")
Close the socket.
Definition TSocket.cxx:382
Bool_t RecvProcessIDs(TMessage *mess)
Receive a message containing process ids.
Definition TSocket.cxx:983
void SetUrl(const char *url)
Definition TSocket.h:161
TInetAddress GetInetAddress() const
Definition TSocket.h:119
Int_t GetCompressionLevel() const
Definition TSocket.h:187
virtual Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
Definition TSocket.cxx:906
TSecContext * GetSecContext() const
Definition TSocket.h:133
virtual Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Send a raw buffer of specified length.
Definition TSocket.cxx:613
void SendProcessIDs(const TMessage &mess)
Check if TProcessIDs must be sent.
Definition TSocket.cxx:677
virtual TInetAddress GetLocalInetAddress()
Return internet address of local host to which the socket is bound.
Definition TSocket.cxx:402
TSecContext * fSecContext
Definition TSocket.h:71
Int_t fTcpWindowSize
Definition TSocket.h:76
Option_t * GetOption() const override
Definition TSocket.h:104
EServiceType
Definition TSocket.h:50
virtual Int_t GetDescriptor() const
Definition TSocket.h:118
Int_t GetCompressionSettings() const
Definition TSocket.h:193
Int_t GetServType() const
Definition TSocket.h:123
EServiceType fServType
Definition TSocket.h:74
void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Used to specify the compression level and algorithm: settings = 100 * algorithm + level.
Definition TSocket.cxx:1106
UInt_t fBytesSent
Definition TSocket.h:67
Int_t fRemoteProtocol
Definition TSocket.h:70
UInt_t fBytesRecv
Definition TSocket.h:66
virtual Bool_t IsValid() const
Definition TSocket.h:138
virtual Int_t Send(const TMessage &mess)
Send a TMessage object.
Definition TSocket.cxx:515
virtual TInetAddress GetSockName(int sock)
Get Internet Protocol (IP) address of host and port #.
Definition TSystem.cxx:2320
virtual void CloseConnection(int sock, Bool_t force=kFALSE)
Close socket connection.
Definition TSystem.cxx:2401
This class represents a WWW compatible URL.
Definition TUrl.h:33
const Int_t n
Definition legend1.C:16