Esempio n. 1
0
void ByteQueue::pop(ByteQueue& data) {
  uint32_t total = data.size() <= buf.size() ? data.size() : buf.size();
  if (!total)
    return;
  memcpy(data.ptr(), (const void*)&buf[0], total);
  buf.erase(buf.begin(), buf.begin() + total);
  data.resize(total);
}
Esempio n. 2
0
void UDPSocket::send(const Address& address, const ByteQueue& data) {
#ifdef _WIN32
  SOCKADDR_IN servaddr;
  memset((void*)&servaddr, 0, sizeof(SOCKADDR_IN));
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = address.ip;
  servaddr.sin_port = address.port;
  sendto(sd, (const char*)data.ptr(), data.size(), 0, (SOCKADDR*)&servaddr, sizeof(SOCKADDR_IN));
#else
  sockaddr_in servaddr;
  memset(&servaddr, 0, sizeof(sockaddr_in));
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = address.ip;
  servaddr.sin_port = address.port;
  sendto(sd, data.ptr(), data.size(), 0, (const sockaddr*)&servaddr, sizeof(sockaddr_in));
#endif
}