13#include <netinet/in.h>
16#include <daq/storage/BinData.h>
18#include "daq/slc/system/TCPServerSocket.h"
19#include "daq/slc/system/Time.h"
24#define MAXBUF 400000000
26int main(
int argc,
char** argv)
29 printf(
"ds_socket2rb : filename hostname port interval\n");
33 int fd = ::open(argv[1], O_RDONLY);
39 printf(
"file2socket::start\n");
41 const std::string host = argv[2];
42 server_socket.open(host, atoi(argv[3]));
44 printf(
"file2socket::accepting\n");
45 TCPSocket socket = server_socket.accept();
46 printf(
"file2socket::accepted\n");
52 int* evtbuf =
new int[10000000];
58 int sstat = read(fd, evtbuf,
sizeof(
int));
60 lseek(fd, 0, SEEK_SET);
69 unsigned int nbyte = evtbuf[0];
70 int rstat = read(fd, (evtbuf + 1), nbyte -
sizeof(
int));
71 if (rstat <= 0)
continue;
72 if (sstat + rstat != evtbuf[0])
continue;
73 unsigned int nbyte_hton = htonl(nbyte);
75 printf(
"nbyte = %u\n", nbyte);
76 socket.write(&nbyte_hton,
sizeof(
int));
77 socket.write(evtbuf, nbyte);
81 const int nth = 10000;
82 if (nrec % nth == 0) {
84 double dt = (t.get() - t0.get());
85 double freq = nth / dt / 1000.;
86 double rate = datasize / dt / 1000. / 1000.;
87 printf(
"Serial = %d Freq = %f [kHz] (%f [kHz]), Rate = %f [MB/s], DataSize = %f [kB/event]\n",
88 nrec, freq, (nrec / (t.get() - t1.get()) / 1000), rate, datasize / 1000. / nth);
Abstract base class for different kinds of events.