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
49TPSocket::TPSocket(TInetAddress addr, const char *service, Int_t size,
50 Int_t tcpwindowsize) : TSocket(addr, service)
51{
52 fSize = size;
53 Init(tcpwindowsize);
54}
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
67 Int_t tcpwindowsize) : TSocket(addr, port)
68{
69 fSize = size;
70 Init(tcpwindowsize);
71}
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,
84 Int_t tcpwindowsize) : TSocket(host, service)
85{
86 fSize = size;
87 Init(tcpwindowsize);
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,
101 Int_t tcpwindowsize)
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
108 Bool_t valid = TSocket::IsValid();
109
110 // perhaps we can use fServType here ... to be checked
111 Bool_t rootdSrv = (strstr(host,"rootd")) ? kTRUE : kFALSE;
112
113 // open the sockets ...
114 if (!rootdSrv || fRemoteProtocol > 9) {
115 if (valid) {
116 fSize = size;
117 Init(tcpwindowsize);
118 }
119 }
120}
121
122////////////////////////////////////////////////////////////////////////////////
123/// Create a parallel socket on a connection already opened via
124/// TSocket sock.
125/// This constructor is provided to optimize TNetFile opening when
126/// instatiated via a call to TNetXNGFile.
127/// Returns when connection has been accepted by remote side. Use IsValid()
128/// to check the validity of the socket. Every socket is added to the TROOT
129/// sockets list which will make sure that any open sockets are properly
130/// closed on program termination.
131
132TPSocket::TPSocket(const char *host, Int_t /* port */, Int_t size, TSocket *sock)
133{
134 // To avoid uninitialization problems when Init is not called ...
135 fSockets = 0;
136 fWriteMonitor = 0;
137 fReadMonitor = 0;
138 fWriteBytesLeft = 0;
139 fReadBytesLeft = 0;
140 fWritePtr = 0;
141 fReadPtr = 0;
142
143 // set to the real value only at end (except for old servers)
144 fSize = 1;
145
146 // We need a opened connection
147 if (!sock) return;
148
149 // Now import existing socket info
150 fSocket = sock->GetDescriptor();
151 fService = sock->GetService();
152 fAddress = sock->GetInetAddress();
154 fBytesSent = sock->GetBytesSent();
155 fBytesRecv = sock->GetBytesRecv();
160
161 // to control the flow
162 Bool_t valid = sock->IsValid();
163
164 // perhaps we can use fServType here ... to be checked
165 Bool_t rootdSrv = (strstr(host,"rootd")) ? kTRUE : kFALSE;
166
167 // open the sockets ...
168 if (!rootdSrv || fRemoteProtocol > 9) {
169 if (valid) {
170 fSize = size;
171 Init(fTcpWindowSize, sock);
172 }
173 }
174
175 // Add to the list if everything OK
176 if (IsValid()) {
178 gROOT->GetListOfSockets()->Add(this);
179 }
180}
181
182////////////////////////////////////////////////////////////////////////////////
183/// Create a parallel socket. This ctor is called by TPServerSocket.
184
186{
187 fSockets = pSockets;
188 fSize = size;
189
190 // set descriptor if simple socket (needed when created
191 // by TPServerSocket)
192 if (fSize <= 1)
193 fSocket = fSockets[0]->GetDescriptor();
194
195 // set socket options (no blocking and no delay)
197 if (fSize > 1)
199
204 fWritePtr = new char*[fSize];
205 fReadPtr = new char*[fSize];
206
207 for (int i = 0; i < fSize; i++) {
210 }
211 fWriteMonitor->DeActivateAll();
212 fReadMonitor->DeActivateAll();
213
214 SetName(fSockets[0]->GetName());
216 fAddress = fSockets[0]->GetInetAddress();
217
218 {
220 gROOT->GetListOfSockets()->Add(this);
221 }
222}
223
224////////////////////////////////////////////////////////////////////////////////
225/// Cleanup the parallel socket.
226
228{
229 Close();
230
231 delete fWriteMonitor;
232 delete fReadMonitor;
233 delete [] fWriteBytesLeft;
234 delete [] fReadBytesLeft;
235 delete [] fWritePtr;
236 delete [] fReadPtr;
237}
238
239////////////////////////////////////////////////////////////////////////////////
240/// Close a parallel socket. If option is "force", calls shutdown(id,2) to
241/// shut down the connection. This will close the connection also
242/// for the parent of this process. Also called via the dtor (without
243/// option "force", call explicitly Close("force") if this is desired).
244
246{
247
248 if (!IsValid()) {
249 // if closing happens too early (e.g. timeout) the underlying
250 // socket may still be open
251 TSocket::Close(option);
252 return;
253 }
254
255 if (fSize <= 1) {
256 TSocket::Close(option);
257 } else {
258 for (int i = 0; i < fSize; i++) {
259 fSockets[i]->Close(option);
260 delete fSockets[i];
261 }
262 }
263 delete [] fSockets;
264 fSockets = 0;
265
266 {
268 gROOT->GetListOfSockets()->Remove(this);
269 }
270}
271
272////////////////////////////////////////////////////////////////////////////////
273/// Create a parallel socket to the specified host.
274
275void TPSocket::Init(Int_t tcpwindowsize, TSocket *sock)
276{
277 fSockets = 0;
278 fWriteMonitor = 0;
279 fReadMonitor = 0;
280 fWriteBytesLeft = 0;
281 fReadBytesLeft = 0;
282 fWritePtr = 0;
283 fReadPtr = 0;
284
285 if ((sock && !sock->IsValid()) || !TSocket::IsValid())
286 return;
287
288 Int_t i = 0;
289
290 if (fSize <= 1) {
291 // check if single mode
292 fSize = 1;
293
294 // set socket options (no delay)
295 if (sock)
296 sock->SetOption(kNoDelay, 1);
297 else
299
300 // if yes, communicate this to server
301 // (size = 0 for backward compatibility)
302 if (sock) {
303 if (sock->Send((Int_t)0, (Int_t)0) < 0)
304 Warning("Init", "%p: problems sending (0,0)", sock);
305 } else {
306 if (TSocket::Send((Int_t)0, (Int_t)0) < 0)
307 Warning("Init", "problems sending (0,0)");
308 }
309
310 // needs to fill additional private members
311 fSockets = new TSocket*[1];
312 fSockets[0]= (TSocket *)this;
313
314 } else {
315
316 // create server that will be used to accept the parallel sockets from
317 // the remote host, use port=0 to scan for a free port
318 TServerSocket ss(0, kFALSE, fSize, tcpwindowsize);
319
320 // send the local port number of the just created server socket and the
321 // number of desired parallel sockets
322 if (sock) {
323 if (sock->Send(ss.GetLocalPort(), fSize) < 0)
324 Warning("Init", "%p: problems sending size", sock);
325 } else {
326 if (TSocket::Send(ss.GetLocalPort(), fSize) < 0)
327 Warning("Init", "problems sending size");
328 }
329
330 fSockets = new TSocket*[fSize];
331
332 // establish fSize parallel socket connections between client and server
333 for (i = 0; i < fSize; i++) {
334 fSockets[i] = ss.Accept();
336 gROOT->GetListOfSockets()->Remove(fSockets[i]);
337 }
338
339 // set socket options (no blocking and no delay)
342
343 // close original socket
344 if (sock)
345 sock->Close();
346 else
347 gSystem->CloseConnection(fSocket, kFALSE);
348 fSocket = -1;
349 }
350
355 fWritePtr = new char*[fSize];
356 fReadPtr = new char*[fSize];
357
358 for (i = 0; i < fSize; i++) {
361 }
362 fWriteMonitor->DeActivateAll();
363 fReadMonitor->DeActivateAll();
364}
365
366////////////////////////////////////////////////////////////////////////////////
367/// Return internet address of local host to which the socket is bound.
368/// In case of error TInetAddress::IsValid() returns kFALSE.
369
371{
372 if (fSize<= 1)
374
375 if (IsValid()) {
376 if (fLocalAddress.GetPort() == -1)
377 fLocalAddress = gSystem->GetSockName(fSockets[0]->GetDescriptor());
378 return fLocalAddress;
379 }
380 return TInetAddress();
381}
382
383////////////////////////////////////////////////////////////////////////////////
384/// Return socket descriptor
385
387{
388 if (fSize <= 1)
389 return TSocket::GetDescriptor();
390
391 return fSockets ? fSockets[0]->GetDescriptor() : -1;
392
393}
394
395////////////////////////////////////////////////////////////////////////////////
396/// Send a TMessage object. Returns the number of bytes in the TMessage
397/// that were sent and -1 in case of error. In case the TMessage::What
398/// has been or'ed with kMESS_ACK, the call will only return after having
399/// received an acknowledgement, making the sending process synchronous.
400/// Returns -4 in case of kNoBlock and errno == EWOULDBLOCK.
401
403{
404 if (!fSockets || fSize <= 1)
405 return TSocket::Send(mess); // only the case when called via Init()
406
407 if (!IsValid()) {
408 return -1;
409 }
410
411 if (mess.IsReading()) {
412 Error("Send", "cannot send a message used for reading");
413 return -1;
414 }
415
416 // send streamer infos in case schema evolution is enabled in the TMessage
417 SendStreamerInfos(mess);
418
419 // send the process id's so TRefs work
420 SendProcessIDs(mess);
421
422 mess.SetLength(); //write length in first word of buffer
423
424 if (GetCompressionLevel() > 0 && mess.GetCompressionLevel() == 0)
425 const_cast<TMessage&>(mess).SetCompressionSettings(fCompress);
426
427 if (mess.GetCompressionLevel() > 0)
428 const_cast<TMessage&>(mess).Compress();
429
430 char *mbuf = mess.Buffer();
431 Int_t mlen = mess.Length();
432 if (mess.CompBuffer()) {
433 mbuf = mess.CompBuffer();
434 mlen = mess.CompLength();
435 }
436
437 Int_t nsent, ulen = (Int_t) sizeof(UInt_t);
438 // send length
439 if ((nsent = SendRaw(mbuf, ulen, kDefault)) <= 0)
440 return nsent;
441
442 // send buffer (this might go in parallel)
443 if ((nsent = SendRaw(mbuf+ulen, mlen-ulen, kDefault)) <= 0)
444 return nsent;
445
446 // if acknowledgement is desired, wait for it
447 if (mess.What() & kMESS_ACK) {
448 char buf[2];
449 if (RecvRaw(buf, sizeof(buf), kDefault) < 0)
450 return -1;
451 if (strncmp(buf, "ok", 2)) {
452 Error("Send", "bad acknowledgement");
453 return -1;
454 }
455 }
456
457 return nsent; //length - length header
458}
459
460////////////////////////////////////////////////////////////////////////////////
461/// Send a raw buffer of specified length. Returns the number of bytes
462/// send and -1 in case of error.
463
464Int_t TPSocket::SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt)
465{
466 if (fSize == 1)
467 return TSocket::SendRaw(buffer,length,opt);
468
469 if (!fSockets) return -1;
470
471 // if data buffer size < 4K use only one socket
472 Int_t i, nsocks = fSize, len = length;
473 if (len < 4096)
474 nsocks = 1;
475
477 if (nsocks == 1)
478 sendopt = kDefault;
479
480 if (opt != kDefault) {
481 nsocks = 1;
482 sendopt = opt;
483 }
484
485 if (nsocks == 1)
486 fSockets[0]->SetOption(kNoBlock, 0);
487 else
488 fSockets[0]->SetOption(kNoBlock, 1);
489
490 // setup pointer appropriately for transferring data equally on the
491 // parallel sockets
492 for (i = 0; i < nsocks; i++) {
493 fWriteBytesLeft[i] = len/nsocks;
494 fWritePtr[i] = (char *)buffer + (i*fWriteBytesLeft[i]);
495 fWriteMonitor->Activate(fSockets[i]);
496 }
497 fWriteBytesLeft[nsocks-1] += len%nsocks;
498
499 // send the data on the parallel sockets
500 while (len > 0) {
501 TSocket *s = fWriteMonitor->Select();
502 for (int is = 0; is < nsocks; is++) {
503 if (s == fSockets[is]) {
504 if (fWriteBytesLeft[is] > 0) {
505 Int_t nsent;
506again:
508 if ((nsent = fSockets[is]->SendRaw(fWritePtr[is],
509 fWriteBytesLeft[is],
510 sendopt)) <= 0) {
511 if (nsent == -4) {
512 // got EAGAIN/EWOULDBLOCK error, keep trying...
513 goto again;
514 }
515 fWriteMonitor->DeActivateAll();
516 if (nsent == -5) {
517 // connection reset by peer or broken ...
519 Close();
520 }
521 return -1;
522 }
523 if (opt == kDontBlock) {
524 fWriteMonitor->DeActivateAll();
525 return nsent;
526 }
527 fWriteBytesLeft[is] -= nsent;
528 fWritePtr[is] += nsent;
529 len -= nsent;
530 }
531 }
532 }
533 }
534 fWriteMonitor->DeActivateAll();
535
536 return length;
537}
538
539////////////////////////////////////////////////////////////////////////////////
540/// Receive a TMessage object. The user must delete the TMessage object.
541/// Returns length of message in bytes (can be 0 if other side of connection
542/// is closed) or -1 in case of error or -4 in case a non-blocking socket would
543/// block (i.e. there is nothing to be read). In those case mess == 0.
544
546{
547 if (fSize <= 1)
548 return TSocket::Recv(mess);
549
550 if (!IsValid()) {
551 mess = 0;
552 return -1;
553 }
554
555oncemore:
556 Int_t n;
557 UInt_t len;
558 if ((n = RecvRaw(&len, sizeof(UInt_t), kDefault)) <= 0) {
559 mess = 0;
560 return n;
561 }
562 len = net2host(len); //from network to host byte order
563
564 if (len > (std::numeric_limits<decltype(len)>::max() - sizeof(decltype(len)))) {
565 Error("Recv", "Buffer length is %u and %u+sizeof(UInt_t) cannot be represented as an UInt_t.", len, len);
566 return -1;
567 }
568
569 char *buf = new char[len+sizeof(UInt_t)];
570 if ((n = RecvRaw(buf+sizeof(UInt_t), len, kDefault)) <= 0) {
571 delete [] buf;
572 mess = 0;
573 return n;
574 }
575
576 mess = new TMessage(buf, len+sizeof(UInt_t));
577
578 // receive any streamer infos
579 if (RecvStreamerInfos(mess))
580 goto oncemore;
581
582 // receive any process ids
583 if (RecvProcessIDs(mess))
584 goto oncemore;
585
586 if (mess->What() & kMESS_ACK) {
587 char ok[2] = { 'o', 'k' };
588 if (SendRaw(ok, sizeof(ok), kDefault) < 0) {
589 delete mess;
590 mess = 0;
591 return -1;
592 }
593 mess->SetWhat(mess->What() & ~kMESS_ACK);
594 }
595
596 return n;
597}
598
599////////////////////////////////////////////////////////////////////////////////
600/// Send a raw buffer of specified length. Returns the number of bytes
601/// sent or -1 in case of error.
602
604{
605 if (fSize <= 1)
606 return TSocket::RecvRaw(buffer,length,opt);
607
608 if (!fSockets) return -1;
609
610 // if data buffer size < 4K use only one socket
611 Int_t i, nsocks = fSize, len = length;
612 if (len < 4096)
613 nsocks = 1;
614
616 if (nsocks == 1)
617 recvopt = kDefault;
618
619 if (opt != kDefault) {
620 nsocks = 1;
621 recvopt = opt;
622 }
623
624 if (nsocks == 1)
625 fSockets[0]->SetOption(kNoBlock, 0);
626 else
627 fSockets[0]->SetOption(kNoBlock, 1);
628
629 // setup pointer appropriately for transferring data equally on the
630 // parallel sockets
631 for (i = 0; i < nsocks; i++) {
632 fReadBytesLeft[i] = len/nsocks;
633 fReadPtr[i] = (char *)buffer + (i*fReadBytesLeft[i]);
634 fReadMonitor->Activate(fSockets[i]);
635 }
636 fReadBytesLeft[nsocks-1] += len%nsocks;
637
638 // start receiving data on all sockets. Receive data as and when
639 // they are available on a socket by by using select.
640 // Exit the loop as soon as all data has been received.
641 while (len > 0) {
642 TSocket *s = fReadMonitor->Select();
643 for (int is = 0; is < nsocks; is++) {
644 if (s == fSockets[is]) {
645 if (fReadBytesLeft[is] > 0) {
646 Int_t nrecv;
648 if ((nrecv = fSockets[is]->RecvRaw(fReadPtr[is],
649 fReadBytesLeft[is],
650 recvopt)) <= 0) {
651 fReadMonitor->DeActivateAll();
652 if (nrecv == -5) {
653 // connection reset by peer or broken ...
655 Close();
656 }
657 return -1;
658 }
659 if (opt == kDontBlock) {
660 fReadMonitor->DeActivateAll();
661 return nrecv;
662 }
663 fReadBytesLeft[is] -= nrecv;
664 fReadPtr[is] += nrecv;
665 len -= nrecv;
666 }
667 }
668 }
669 }
670 fReadMonitor->DeActivateAll();
671
672 return length;
673}
674
675////////////////////////////////////////////////////////////////////////////////
676/// Set socket options.
677
679{
680 if (fSize <= 1)
681 return TSocket::SetOption(opt,val);
682
683 Int_t ret = 0;
684 for (int i = 0; i < fSize; i++)
685 ret = fSockets[i]->SetOption(opt, val);
686 return ret;
687}
688
689////////////////////////////////////////////////////////////////////////////////
690/// Get socket options. Returns -1 in case of error.
691
693{
694 if (fSize <= 1)
695 return TSocket::GetOption(opt,val);
696
697 Int_t ret = 0;
698 for (int i = 0; i < fSize; i++)
699 ret = fSockets[i]->GetOption(opt, val);
700 return ret;
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// Returns error code. Meaning depends on context where it is called.
705/// If no error condition returns 0 else a value < 0.
706
708{
709 if (fSize <= 1)
710 return TSocket::GetErrorCode();
711
712 return fSockets[0] ? fSockets[0]->GetErrorCode() : 0;
713}
UShort_t net2host(UShort_t x)
Definition Bytes.h:561
@ kMESS_ACK
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
char * ret
Definition Rotated.cxx:221
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
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
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
#define gROOT
Definition TROOT.h:417
externTVirtualMutex * gROOTMutex
Definition TROOT.h:63
char * Compress(const char *str)
Remove all blanks from the string str.
Definition TString.cxx:2579
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
externTSystem * gSystem
Definition TSystem.h:582
#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.
UInt_t What() const
Definition TMessage.h:77
void SetLength() const
Set the message length at the beginning of the message buffer.
Definition TMessage.cxx:208
char * CompBuffer() const
Definition TMessage.h:91
Int_t GetCompressionLevel() const
Definition TMessage.h:108
Int_t CompLength() const
Definition TMessage.h:92
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:228
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:1084
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:888
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1098
void ResetBit(UInt_t f)
Definition TObject.h:203
Int_t Send(const TMessage &mess) override
Send a TMessage object.
Definition TPSocket.cxx:402
Int_t Recv(TMessage *&mess) override
Receive a TMessage object.
Definition TPSocket.cxx:545
TPSocket(TSocket *pSockets[], Int_t size)
Create a parallel socket. This ctor is called by TPServerSocket.
Definition TPSocket.cxx:185
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:245
virtual ~TPSocket()
Cleanup the parallel socket.
Definition TPSocket.cxx:227
void Init(Int_t tcpwindowsize, TSocket *sock=nullptr)
Create a parallel socket to the specified host.
Definition TPSocket.cxx:275
TMonitor * fReadMonitor
Definition TPSocket.h:40
Int_t GetErrorCode() const
Returns error code.
Definition TPSocket.cxx:707
Int_t SetOption(ESockOptions opt, Int_t val) override
Set socket options.
Definition TPSocket.cxx:678
TInetAddress GetLocalInetAddress() override
Return internet address of local host to which the socket is bound.
Definition TPSocket.cxx:370
Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault) override
Send a raw buffer of specified length.
Definition TPSocket.cxx:603
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:386
Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault) override
Send a raw buffer of specified length.
Definition TPSocket.cxx:464
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:63
Int_t fCompress
Definition TSocket.h:66
virtual Int_t SetOption(ESockOptions opt, Int_t val)
Set socket options.
Definition TSocket.cxx:1017
Int_t fSocket
Definition TSocket.h:71
friend class TServerSocket
Definition TSocket.h:41
Int_t GetErrorCode() const
Returns error code.
Definition TSocket.cxx:1039
UInt_t GetBytesRecv() const
Definition TSocket.h:121
void SendStreamerInfos(const TMessage &mess)
Check if TStreamerInfo must be sent.
Definition TSocket.cxx:638
const char * GetService() const
Definition TSocket.h:117
TSocket()
Definition TSocket.h:85
TString fService
Definition TSocket.h:69
Bool_t RecvStreamerInfos(TMessage *mess)
Receive a message containing streamer infos.
Definition TSocket.cxx:932
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Definition TSocket.cxx:807
Int_t GetRemoteProtocol() const
Definition TSocket.h:127
UInt_t GetBytesSent() const
Definition TSocket.h:120
TInetAddress fLocalAddress
Definition TSocket.h:67
Int_t GetTcpWindowSize() const
Definition TSocket.h:128
@ kBrokenConn
Definition TSocket.h:45
virtual void Close(Option_t *opt="")
Close the socket.
Definition TSocket.cxx:378
Bool_t RecvProcessIDs(TMessage *mess)
Receive a message containing process ids.
Definition TSocket.cxx:979
TInetAddress GetInetAddress() const
Definition TSocket.h:114
Int_t GetCompressionLevel() const
Definition TSocket.h:174
virtual Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
Definition TSocket.cxx:902
virtual Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Send a raw buffer of specified length.
Definition TSocket.cxx:609
void SendProcessIDs(const TMessage &mess)
Check if TProcessIDs must be sent.
Definition TSocket.cxx:673
virtual TInetAddress GetLocalInetAddress()
Return internet address of local host to which the socket is bound.
Definition TSocket.cxx:398
Int_t fTcpWindowSize
Definition TSocket.h:72
Option_t * GetOption() const override
Definition TSocket.h:99
EServiceType
Definition TSocket.h:48
virtual Int_t GetDescriptor() const
Definition TSocket.h:113
Int_t GetCompressionSettings() const
Definition TSocket.h:180
Int_t GetServType() const
Definition TSocket.h:118
EServiceType fServType
Definition TSocket.h:70
void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Used to specify the compression level and algorithm: settings = 100 * algorithm + level.
Definition TSocket.cxx:1102
UInt_t fBytesSent
Definition TSocket.h:65
Int_t fRemoteProtocol
Definition TSocket.h:68
UInt_t fBytesRecv
Definition TSocket.h:64
virtual Bool_t IsValid() const
Definition TSocket.h:131
virtual Int_t Send(const TMessage &mess)
Send a TMessage object.
Definition TSocket.cxx:511
const Int_t n
Definition legend1.C:16