Exemplo n.º 1
0
int main(int argc, char* argv[])
{
  Parent par;

  int chpid;
  if((chpid=fork())==0)
  {
     Child ch;
     ch.run();
  }
  par.run();

  int status;
  wait(&status);

  return 0;
}
Exemplo n.º 2
0
int main(int argc, char* argv[])
{
  io_service pio;
  ip::tcp::acceptor acceptor(pio,ip::tcp::endpoint(ip::tcp::v4(),2988));
  ip::tcp::socket socket(pio);

  int chpid;
  if((chpid=fork())==0)
  {
     Child ch;
     ch.run();
  }
  acceptor.accept(socket);
  char buf[1024];
  socket.read_some(buffer(buf,1024));
  cout << format("get message: %s\n")%buf;
  socket.close();

  int status;
  wait(&status);

  return 0;
}