Пример #1
0
static void wol(Socket::ptr socket, const std::string &macAddress) {
  MORDOR_ASSERT(macAddress.size() == 6u);
  std::string message;
  message.append(6u, (char)0xff);
  for(size_t i = 0; i < 16; ++i)
      message.append(macAddress);
  socket->send(message.c_str(), message.size());
}
Пример #2
0
void do_ping(Socket::ptr sock, string ip, int port){
    debug("Pinging %s:%d\n", ip.c_str(), port);
    sock->connect(ip.c_str(), port);
    sock->send(PING + NEWLINE + NEWLINE);
    string response = sock->recv();
    if(response.substr(0, PONG.length()) != PONG){
        throw(gollum2411::socket_error("No PONG received"));
    }
}
Пример #3
0
  void handleConnect(Socket::ptr socket) {
      char buf[10];
      while(1) { 
          //receive will switch the contex to epoll fiber
             size_t len = socket->receive(buf, sizeof(buf));
             if(len == 0) {
                printf("receive 0, closed by remote\n");
                break;
             }
             socket->send(buf, len);
       }
       socket->shutdown();
 }