Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JLigier.cc
Go to the documentation of this file.
1#include <iostream>
2#include <iomanip>
3#include <string>
4#include <sstream>
5#include <deque>
6#include <set>
7
8#include "Jeep/JParser.hh"
9#include "Jeep/JMessage.hh"
10#include "JLang/JMemory.hh"
12#include "JNet/JTCPSocket.hh"
14#include "JNet/JServerSocket.hh"
15#include "JNet/JSelect.hh"
16#include "JNet/JControlHost.hh"
18#include "JMath/JConstants.hh"
19
20
21namespace JNET {
22
23
24 using namespace JPP;
25
26
27 template<class T> class JMemory_t : public JMalloc<T> {}; // Memory manager
28
31
32
33 /**
34 * Get total size of internet packet.
35 *
36 * \param prefix prefix
37 * \return number of bytes
38 */
39 inline int getSizeOfPacket(const JPrefix_t& prefix)
40 {
41 return prefix.getSize() + sizeof(JPrefix_t);
42 }
43
44
45 /**
46 * Set total size of internet packet.
47 *
48 * \param size number of bytes
49 * \param prefix prefix
50 */
51 inline void setSizeOfPacket(const int size, JPrefix_t& prefix)
52 {
53 prefix.setSize(size - sizeof(JPrefix_t));
54 }
55
56
57 /**
58 * Data structure of a ControlHost message.
59 * This data structure consists of a copy of the ControlHost prefix and
60 * an array of bytes (including the ControlHost prefix).
61 * A new array of bytes is created by the appropriate constructor.
62 * The allocated memory is released upon destruction of the last object of this class.
63 */
64 class JDispatch :
65 public JPrefix_t,
66 public JSharedCounter
67 {
68 public:
69
71
72 static long long int MEMORY_TOTAL; //!< Total size of data [Bytes]
73 static long long int MEMORY_LIMIT; //!< Limit size of data [Bytes]
74
75 /**
76 * Default constructor.
77 */
79 JPrefix_t(),
81 buffer(NULL)
82 {}
83
84
85 /**
86 * Constructor.
87 * Note that the input data should contain a copy of the prefix.
88 *
89 * \param prefix prefix
90 * \param data data
91 */
92 JDispatch(const JPrefix_t& prefix,
93 const char* data) :
94 JPrefix_t(prefix),
96 {
97 create();
98
99 memcpy(this->buffer, data, size());
100 }
101
102
103 /**
104 * Constructor.
105 * Note that the given message is appended to a copy of the prefix.
106 *
107 * \param tag tag
108 * \param message message
109 */
110 JDispatch(const JTag& tag,
111 const std::string& message) :
112 JPrefix_t(tag, message.size()),
114 {
115 create();
116
117 memcpy(this->buffer, static_cast<const JPrefix_t*>(this), sizeof(JPrefix_t));
118
119 memcpy(this->buffer + sizeof(JPrefix_t), message.data(), message.size());
120 }
121
122
123 /**
124 * Copy constructor.
125 *
126 * \param message message
127 */
128 JDispatch(const JDispatch& message)
129 {
130 static_cast<JPrefix_t&>(*this) = message;
131
132 buffer = message.buffer;
133
134 attach(message);
135 }
136
137
138 /**
139 * Destructor.
140 */
142 {
143 if (detach()) {
144 release();
145 }
146 }
147
148
149 /**
150 * Assignment operator.
151 *
152 * \param message message
153 * \return this JDispatch
154 */
155 JDispatch& operator=(const JDispatch& message)
156 {
157 if (buffer != message.buffer) {
158
159 if (detach()) {
160 release();
161 }
162
163 buffer = message.buffer;
164
165 attach(message);
166 }
167
168 return *this;
169 }
170
171
172 /**
173 * Type conversion operator.
174 *
175 * \return socket output buffer
176 */
177 operator JSocketOutputBuffer () const
178 {
179 return JSocketOutputBuffer(this->data(), this->size());
180 }
181
182
183 /**
184 * Get size.
185 *
186 * \return number of bytes
187 */
188 int size() const
189 {
190 return getSizeOfPacket(static_cast<const JPrefix_t&>(*this));
191 }
192
193
194 /**
195 * Get data.
196 *
197 * \return pointer to data
198 */
199 const char* data() const
200 {
201 return buffer;
202 }
203
204
205 protected:
206 /**
207 * Allocate memory.
208 */
209 void create()
210 {
212
213 if (buffer != NULL) {
214
216
217 MEMORY_TOTAL += size();
218
219 } else {
220
221 throw JMallocException("Not enough space in memory.");
222 }
223 }
224
225
226 /**
227 * Release memory.
228 */
229 void release()
230 {
232
233 MEMORY_TOTAL -= size();
234 }
235
236 char* buffer;
237 };
238
239
240 /**
241 * ControlHost client manager.
242 */
243 class JClient :
244 public JTCPSocket
245 {
246 public:
247
248
249 static unsigned int QUEUE_LIMIT; //!< Maximum number of messages in queue
250
251
252 /**
253 * Default constructor.
254 */
256 JTCPSocket(),
257 in (*this),
258 out(*this),
259 requestAll(false),
261 {}
262
263
264 /**
265 * Constructor.
266 *
267 * \param socket socket
268 */
269 JClient(const JTCPSocket& socket) :
270 JTCPSocket(socket),
271 in (*this),
272 out(*this),
273 requestAll(false),
275 {}
276
277
278 /**
279 * Get nick name.
280 *
281 * \return nick name
282 */
283 const std::string& getNickname() const
284 {
285 return nick_name;
286 }
287
288
289 /**
290 * Set nick name.
291 *
292 * \param nick_name nick name
293 */
294 void setNickname(const std::string& nick_name)
295 {
296 this->nick_name = nick_name;
297 }
298
299
300 /**
301 * Check request.
302 *
303 * \return true if request can be honoured; else false
304 */
305 bool checkRequest() const
306 {
307 return requestAll || requestCounter != 0;
308 }
309
310
311 /**
312 * Increment request by one.
313 */
315 {
317 }
318
319
320 /**
321 * Decrement request by one.
322 */
324 {
326 }
327
328
329 /**
330 * Set no request.
331 */
333 {
334 requestAll = true;
335 }
336
337
338 /**
339 * Get subscription.
340 *
341 * \return subscription
342 */
344 {
345 return subscriptionAll;
346 }
347
348
349 /**
350 * Get subscription.
351 *
352 * \return subscription
353 */
355 {
356 return subscriptionAny;
357 }
358
359
360 /**
361 * Set subcription.
362 *
363 * \param subscription subscription
364 * \return true of OK; else false
365 */
366 bool setSubscription(const std::string& subscription)
367 {
368 using namespace std;
369
370 subscriptionAll.clear();
371 subscriptionAny.clear();
372
373 try {
374
375 char c;
376 JTag tag;
377
378 for (istringstream is(subscription); is >> c >> tag; ) {
379 if (c == SUBSCRIBE_ALL) subscriptionAll.insert(tag);
380 else if (c == SUBSCRIBE_ANY) subscriptionAny.insert(tag);
381 //else if (c == SUBSCRIBE_SHARED_MEMORY) subscriptionAny.insert(tag);
382 }
383 }
384 catch(const JControlHostException& error) {
385 return false;
386 }
387
388 return true;
389 }
390
391
392 /**
393 * Check subscription for given prefix.
394 *
395 * \param prefix prefix
396 * \return true if subscription valid; else false
397 */
398 bool checkSubscriptionAll(const JPrefix_t& prefix) const
399 {
400 return subscriptionAll.find(prefix) != subscriptionAll.end();
401 }
402
403
404 /**
405 * Check subscription for given prefix.
406 *
407 * \param prefix prefix
408 * \return true if subscription valid; else false
409 */
410 bool checkSubscriptionAny(const JPrefix_t& prefix) const
411 {
412 return subscriptionAny.find(prefix) != subscriptionAny.end() && checkRequest() && queue.size() < QUEUE_LIMIT;
413 }
414
415
416 /**
417 * Check subscription for given prefix.
418 *
419 * \param prefix prefix
420 * \return true if subscription valid; else false
421 */
422 bool checkSubscription(const JPrefix_t& prefix) const
423 {
424 return checkSubscriptionAll(prefix) || checkSubscriptionAny(prefix);
425 }
426
427
428 /**
429 * Add message to client queues depending on subscription of each client.
430 * Note that adding a message may result in dropping (other) messages.
431 *
432 * \param message message
433 */
434 void add(const JDispatch& message)
435 {
436 if (checkSubscription(message)) {
437
438 queue.push_back(message);
439
440 if (queue.size() > QUEUE_LIMIT) {
441 drop();
442 }
443 }
444 }
445
446
447 /**
448 * Drop all messages for which the client has not the 'all' subscription.
449 */
450 void drop()
451 {
452 for (std::deque<JDispatch>::iterator i = queue.begin(); i != queue.end(); ) {
453 if (!checkSubscriptionAll(*i) && (i != queue.begin() || !out.isBusy()))
454 i = queue.erase(i);
455 else
456 ++i;
457 }
458 }
459
460
461 JSocketInputChannel_t in; //!< reader for incoming messages
462 JSocketNonblockingWriter out; //!< writer for outgoing messages
463 std::deque<JDispatch> queue; //!< queue for outgoing messages
464
465 protected:
468 std::string nick_name;
471 };
472
473
474 /**
475 * List of ControlHost client managers.
476 */
478 public std::vector<JClient>
479 {
480 public:
481 /**
482 * Default constructor.
483 */
485 std::vector<JClient>()
486 {}
487
488
489 /**
490 * Add message to client queues depending on subscription of each client.
491 *
492 * \param message message
493 */
494 void add(const JDispatch& message)
495 {
496 for (iterator i = this->begin(); i != this->end(); ++i) {
497 i->add(message);
498 }
499 }
500
501
502 /**
503 * Drop all messages from client queues for which the client has not the 'all' subscription.
504 */
505 void drop()
506 {
507 for (iterator i = this->begin(); i != this->end(); ++i) {
508 i->drop();
509 }
510 }
511 };
512
513
514 /**
515 * Print message.
516 *
517 * \param out output stream
518 * \param message message
519 * \return output stream
520 */
521 inline std::ostream& operator<<(std::ostream& out, const JDispatch& message)
522 {
523 return out << "(" << message.getTag() << "," << message.size() << ")";
524 }
525
526
527 /**
528 * Print socket.
529 *
530 * \param out output stream
531 * \param socket socket
532 * \return output stream
533 */
534 inline std::ostream& operator<<(std::ostream& out, const JSocket& socket)
535 {
536 return out << "[" << socket.getFileDescriptor() << "]";
537 }
538
539
540 /**
541 * Print socket status.
542 *
543 * \param out output stream
544 * \param status socket status
545 * \return output stream
546 */
547 inline std::ostream& operator<<(std::ostream& out, const JSocketStatus& status)
548 {
549 return out << "(" << status.isReady() << "," << status.getCounter() << ")";
550 }
551
552
553 /**
554 * Print socket input buffer.
555 *
556 * \param out output stream
557 * \param buffer socket buffer
558 * \return output stream
559 */
560 inline std::ostream& operator<<(std::ostream& out, const JSocketInputBuffer& buffer)
561 {
562 return out << "(" << buffer.isReady() << "," << buffer.getCounter() << "," << buffer.getSize() << ")";
563 }
564
565
566 long long int JDispatch::MEMORY_TOTAL = 0; //!< Total memory allocation.
567 long long int JDispatch::MEMORY_LIMIT; //!< Limit memory allocation.
568
569 unsigned int JClient::QUEUE_LIMIT; //!< queue size limit
570}
571
572
573/**
574 * \file
575 *
576 * Quicksilver Messenger Service - a ControlHost server.
577 * \author mdejong
578 */
579int main(int argc, char* argv[])
580{
581 using namespace std;
582 using namespace JPP;
583
584 int port;
585 int backlog;
586 int timeout_us;
587 int buffer_size;
588 int debug;
589
590 try {
591
592 JParser<> zap("ControlHost server.");
593
594 zap['P'] = make_field(port) = DISPATCH_PORT;
595 zap['q'] = make_field(backlog) = 1024;
596 zap['T'] = make_field(timeout_us) = 5;
597 zap['s'] = make_field(buffer_size) = JSocket::getDefaultBufferSize();
598 zap['Q'] = make_field(JClient::QUEUE_LIMIT) = 100;
599 zap['M'] = make_field(JDispatch::MEMORY_LIMIT) = (JSYSTEM::getRAM() >> 1);
600 zap['d'] = make_field(debug) = 0;
601
602 zap(argc, argv);
603 }
604 catch(const exception &error) {
605 FATAL(error.what() << endl);
606 }
607
608
609 JServerSocket server(port, backlog);
610 JSelect select;
611 JClientList clientList;
612
613
614 DEBUG("Port " << setw(10) << port << endl);
615 DEBUG("Memory limit " << setw(10) << JDispatch::MEMORY_LIMIT << endl);
616 DEBUG("Queue limit " << setw(10) << JClient::QUEUE_LIMIT << endl);
617
618
619 for ( ; ; ) {
620
621 select.reset();
622 select.setReaderMask(server);
623
624 for (JClientList::iterator client = clientList.begin(); client != clientList.end(); ++client) {
625
626 if (!client->in.isReady()) {
627 select.setReaderMask(*client);
628 }
629
630 if (client->out.isReset()) {
631
632 if (!client->queue.empty()) {
633
634 DEBUG("Client" << *client << ".set" << client->queue.front() << endl);
635
636 client->out.set(client->queue.front());
637 client->decrementRequest();
638
639 select.setWriterMask(*client);
640 }
641
642 } else if (client->out.isBusy()) {
643
644 select.setWriterMask(*client);
645 }
646 }
647
648 int nfds = 0;
649
650 try {
651 nfds = select(timeout_us);
652 }
653 catch(const exception& error) {
654 ERROR("" << error.what() << endl);
655 }
656
657 if (nfds > 0) {
658
659 for (JClientList::iterator client = clientList.begin(); client != clientList.end(); ) {
660
661 try {
662
663 if (select.hasReaderMask(*client)) {
664
665 try {
666 client->in.read();
667 }
668 catch(const exception& error) {
669
670 ERROR("Remove (3) client" << *client << "<" << client->getNickname() << ">: " << error.what() << endl);
671
672 if (client->getNickname() != "") {
673 clientList.add(JDispatch(DISPTAG_Died, client->getNickname()));
674 }
675
676 client->shutdown();
677
678 client = clientList.erase(client);
679
680 continue;
681 }
682
683 DEBUG("Client" << *client << ".read" << static_cast<const JSocketInputBuffer&>(client->in) << endl);
684 }
685
686 if (client->in.isReady()) {
687
688 DEBUG("Message" << *client << ' ' << client->in.prefix.c_str() << ' ' << client->in.size() << endl);
689
690 bool special = JControlHost::maybe_special(client->in.prefix);
691
692 if (special) {
693
694 client->in.seekg(sizeof(JPrefix_t)); // skip prefix
695
696 if (client->in.prefix.getTag() == DISPTAG_Subscribe) {
697
698 client->setSubscription(string(client->in.getRemainingData(), client->in.getRemainingSize()));
699
700 } else if (client->in.prefix.getTag() == DISPTAG_MyId) {
701
702 client->setNickname(string(client->in.getRemainingData(), client->in.getRemainingSize()));
703
704 clientList.add(JDispatch(DISPTAG_Born, client->getNickname()));
705
706 } else if (client->in.prefix.getTag() == DISPTAG_Gime) {
707
708 client->incrementRequest();
709
710 } else if (client->in.prefix.getTag() == DISPTAG_Always) {
711
712 client->setRequestAll();
713
714 } else if (client->in.prefix.getTag() == DISPTAG_WhereIs) {
715
716 string nick_name(client->in.getRemainingData(), client->in.getRemainingSize());
717 string buffer;
718
719 for (JClientList::iterator i = clientList.begin(); i != clientList.end(); ++i) {
720 if (i->getNickname() == nick_name) {
721 buffer += " " + i->getHostname();
722 }
723 }
724
725 JControlHost socket(*client);
726
727 socket.PutFullString(DISPTAG_WhereIs, buffer.substr(buffer.empty() ? 0 : 1));
728
729 DEBUG("Remove (1) client" << *client << endl);
730
731 client->shutdown();
732
733 client = clientList.erase(client);
734
735 continue; // skip any action
736
737 } else if (client->in.prefix.getTag() == DISPTAG_ShowStat) {
738
739 client->shutdown();
740
741 client = clientList.erase(client);
742
743 for (JClientList::iterator i = clientList.begin(); i != clientList.end(); ++i) {
744
745 int total = 0;
746
747 for (std::deque<JDispatch>::const_iterator message = i->queue.begin(); message != i->queue.end(); ++message) {
748 total += message->size();
749 }
750
751 cout << "client[" << i->getFileDescriptor() << "] " << i->getNickname() << endl;
752 cout << "tag - all:";
753 for (std::set<JTag>::const_iterator tag = i->getSubscriptionAll().begin(); tag != i->getSubscriptionAll().end(); ++tag) {
754 cout << ' ' << *tag;
755 }
756 cout << endl;
757 cout << "tag - any:";
758 for (std::set<JTag>::const_iterator tag = i->getSubscriptionAny().begin(); tag != i->getSubscriptionAny().end(); ++tag) {
759 cout << ' ' << *tag;
760 }
761 cout << endl;
762 cout << "queue " << i->queue.size() << ' ' << total << "B" << endl;
763 }
764
765 continue; // skip any action
766
767 } else if (client->in.prefix.getTag() == DISPTAG_Debug) {
768
769 istringstream is(string(client->in.getRemainingData(), client->in.getRemainingSize()));
770
771 is >> debug;
772
773 } else {
774
775 special = false; // not a reserved tag.
776 }
777 }
778
779 if (!special) {
780
781 clientList.add(JDispatch(client->in.prefix, client->in.data()));
782
783 if (JDispatch::MEMORY_TOTAL > JDispatch::MEMORY_LIMIT) {
784
785 WARNING("Memory " << setw(10) << JDispatch::MEMORY_TOTAL << " > " << setw(10) << JDispatch::MEMORY_LIMIT << endl);
786
787 clientList.drop();
788 }
789 }
790
791 client->in.reset();
792 }
793
794 if (select.hasWriterMask(*client)) {
795
796 client->out.write();
797
798 DEBUG("Client" << *client << ".write" << static_cast<const JSocketStatus&>(client->out) << endl);
799
800 if (client->out.isReady()) {
801 client->out.reset();
802 client->queue.pop_front();
803 }
804 }
805
806 ++client;
807 }
808 catch(const exception& error) {
809
810 DEBUG("Remove (2) client" << *client << "<" << client->getNickname() << ">: " << error.what() << endl);
811
812 if (client->getNickname() != "") {
813 clientList.add(JDispatch(DISPTAG_Died, client->getNickname()));
814 }
815
816 client->shutdown();
817
818 client = clientList.erase(client);
819 }
820 }
821
822 if (select.hasReaderMask(server)) {
823
824 JTCPSocket socket(server.getFileDescriptor());
825
828
829 socket.setReuseAddress(true);
830 socket.setKeepAlive (true);
831 socket.setNonBlocking (true);
832
833 DEBUG("New client" << socket << endl);
834
835 clientList.push_back(JClient(socket));
836 }
837 }
838 }
839}
int main(int argc, char *argv[])
Definition JLigier.cc:579
Mathematical constants.
Base class for memory management.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define ERROR(A)
Definition JMessage.hh:66
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define WARNING(A)
Definition JMessage.hh:65
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
System auxiliaries.
int getFileDescriptor() const
Get file descriptor.
Exception for ControlHost.
Exception for failure of memory allocation.
Memory management class for create/release policy based on malloc()/free().
Definition JMemory.hh:82
static JClass_t * create()
Create object in memory.
Definition JMemory.hh:89
static void release(JClass_t *p)
Release memory.
Definition JMemory.hh:112
void initialise()
Initialise counter.
void attach(const JSharedCounter &object)
Attach this counter to given shared counter object.
List of ControlHost client managers.
Definition JLigier.cc:479
void add(const JDispatch &message)
Add message to client queues depending on subscription of each client.
Definition JLigier.cc:494
void drop()
Drop all messages from client queues for which the client has not the 'all' subscription.
Definition JLigier.cc:505
JClientList()
Default constructor.
Definition JLigier.cc:484
ControlHost client manager.
Definition JLigier.cc:245
int requestCounter
Definition JLigier.cc:470
std::deque< JDispatch > queue
queue for outgoing messages
Definition JLigier.cc:463
void setRequestAll()
Set no request.
Definition JLigier.cc:332
const std::set< JTag > & getSubscriptionAny() const
Get subscription.
Definition JLigier.cc:354
const std::string & getNickname() const
Get nick name.
Definition JLigier.cc:283
std::set< JTag > subscriptionAll
Definition JLigier.cc:466
bool checkSubscriptionAll(const JPrefix_t &prefix) const
Check subscription for given prefix.
Definition JLigier.cc:398
bool checkSubscription(const JPrefix_t &prefix) const
Check subscription for given prefix.
Definition JLigier.cc:422
static unsigned int QUEUE_LIMIT
Maximum number of messages in queue.
Definition JLigier.cc:249
JSocketNonblockingWriter out
writer for outgoing messages
Definition JLigier.cc:462
void add(const JDispatch &message)
Add message to client queues depending on subscription of each client.
Definition JLigier.cc:434
void drop()
Drop all messages for which the client has not the 'all' subscription.
Definition JLigier.cc:450
bool checkRequest() const
Check request.
Definition JLigier.cc:305
JClient()
Default constructor.
Definition JLigier.cc:255
std::set< JTag > subscriptionAny
Definition JLigier.cc:467
std::string nick_name
Definition JLigier.cc:468
JClient(const JTCPSocket &socket)
Constructor.
Definition JLigier.cc:269
bool requestAll
Definition JLigier.cc:469
void setNickname(const std::string &nick_name)
Set nick name.
Definition JLigier.cc:294
void incrementRequest()
Increment request by one.
Definition JLigier.cc:314
const std::set< JTag > & getSubscriptionAll() const
Get subscription.
Definition JLigier.cc:343
void decrementRequest()
Decrement request by one.
Definition JLigier.cc:323
bool setSubscription(const std::string &subscription)
Set subcription.
Definition JLigier.cc:366
JSocketInputChannel_t in
reader for incoming messages
Definition JLigier.cc:461
bool checkSubscriptionAny(const JPrefix_t &prefix) const
Check subscription for given prefix.
Definition JLigier.cc:410
ControlHost class.
int PutFullString(const JTag &tag, const std::string &buffer)
Send string.
Data structure of a ControlHost message.
Definition JLigier.cc:67
JDispatch(const JDispatch &message)
Copy constructor.
Definition JLigier.cc:128
int size() const
Get size.
Definition JLigier.cc:188
~JDispatch()
Destructor.
Definition JLigier.cc:141
JMalloc< char > JMemory_t
Definition JLigier.cc:70
void create()
Allocate memory.
Definition JLigier.cc:209
void release()
Release memory.
Definition JLigier.cc:229
static long long int MEMORY_TOTAL
Total size of data [Bytes].
Definition JLigier.cc:72
JDispatch(const JPrefix_t &prefix, const char *data)
Constructor.
Definition JLigier.cc:92
static long long int MEMORY_LIMIT
Limit size of data [Bytes].
Definition JLigier.cc:73
JDispatch(const JTag &tag, const std::string &message)
Constructor.
Definition JLigier.cc:110
JDispatch()
Default constructor.
Definition JLigier.cc:78
JDispatch & operator=(const JDispatch &message)
Assignment operator.
Definition JLigier.cc:155
const char * data() const
Get data.
Definition JLigier.cc:199
ControlHost prefix.
Definition JPrefix.hh:33
int getSize() const
Get size.
Definition JPrefix.hh:62
void setSize(const long long int length)
Set size.
Definition JPrefix.hh:73
Wrapper class for select call.
Definition JSelect.hh:37
TCP server socket.
Auxiliary class for non-blocking socket I/O.
int getSize() const
Get size of pending data.
Socket input channel.
Non-blocking socket writer.
Auxiliary class for non-blocking socket I/O.
int getCounter() const
Get number of I/O attempts.
bool isReady() const
Check ready status.
bool isBusy() const
Check busy status.
Socket class.
Definition JSocket.hh:41
void setReceiveBufferSize(const int size)
Set receive buffer size.
Definition JSocket.hh:148
void setReuseAddress(const bool on)
Set reuse address.
Definition JSocket.hh:126
void setKeepAlive(const bool on)
Set keep alive of socket.
Definition JSocket.hh:104
void setSendBufferSize(const int size)
Set send buffer size.
Definition JSocket.hh:170
TCP socket.
Definition JTCPSocket.hh:30
void setNonBlocking(const bool on)
Set non-blocking of I/O.
Definition JTCPSocket.hh:56
ControlHost tag.
Definition JTag.hh:38
const JTag & getTag() const
Get tag.
Definition JTag.hh:86
Utility class to parse command line options.
Definition JParser.hh:1698
static const size_t buffer_size
std::ostream & operator<<(std::ostream &out, const JAHRSCalibration &calibration)
Write AHRS calibration to output stream.
int getSizeOfPacket(const KM3NETDAQ::JDAQAbstractPreamble &preamble)
Get size of packeet.
JPrefix JPrefix_t
Definition JLigier.cc:29
JSocketInputChannel< JPrefix_t > JSocketInputChannel_t
Definition JLigier.cc:30
@ SUBSCRIBE_ANY
@ SUBSCRIBE_ALL
void setSizeOfPacket(const int size, JPrefix_t &prefix)
Set total size of internet packet.
Definition JLigier.cc:51
JSocketBuffer< const char > JSocketOutputBuffer
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
unsigned long long int getRAM()
Get RAM of this CPU.