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