MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
stream2socket.cc File Reference
#include "mbconfig.h"
#include <cstring>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <cstdio>
#include <cstdlib>
#include <cerrno>
#include <sys/un.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <iostream>
#include <sstream>
#include <vector>
#include "sock.h"
#include "s2s.h"
Include dependency graph for stream2socket.cc:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 58 of file stream2socket.cc.

References buf, s2s_t::dbuf, done, s2s_t::nChannels, s2s_t::parse(), s2s_t::prepare(), s2s_t::send(), and s2s_t::shutdown().

59 {
60  struct s2s_t s2s;
61 
62  try {
63  s2s.parse(argc, argv);
64  s2s.prepare();
65 
66  } catch (...) {
67  s2s.shutdown();
68  exit(EXIT_FAILURE);
69  }
70 
71  if (s2s.nChannels == 0) {
72  std::string buf;
73  std::getline(std::cin, buf);
74 
75  std::istringstream str(buf);
76  for (;; s2s.nChannels++) {
77  double d;
78 
79  str >> d;
80 
81  if (!str) {
82  break;
83  }
84 
85  s2s.dbuf.insert(s2s.dbuf.end(), d);
86  }
87 
88  s2s.send(0);
89 
90  } else {
91  s2s.dbuf.resize(s2s.nChannels);
92  }
93 
94  while (true) {
95  for (int i = 0; i < s2s.nChannels; i++) {
96  std::cin >> s2s.dbuf[i];
97  if (!std::cin) {
98  goto done;
99  }
100  }
101 
102  s2s.send(0);
103  }
104 
105 done:;
106  s2s.shutdown();
107  exit(EXIT_SUCCESS);
108 }
static unsigned done
Definition: gust.cc:209
Definition: s2s.h:54
static doublereal buf[BUFSIZE]
Definition: discctrl.cc:333
void parse(int argc, char *argv[])

Here is the call graph for this function: