Esempio n. 1
0
int Socket::getLocalAddr (InetAddr &sa)
{
  int len = sa.getSize ();
  sockaddr *addr = reinterpret_cast<sockaddr *> (sa.getAddr ());

  if (OS::getsockname (this->getHandle (), addr, &len) == -1)
    return -1;

  sa.setType (addr->sa_family);
  sa.setSize (len);
  return 0;
}
Esempio n. 2
0
ssize_t
SocketDgram::send (const void *buf,
                   size_t n,
                   const InetAddr &addr,
                   int flags) const {
  sockaddr* saddr = (sockaddr*)addr.getAddr();
  int len = addr.getSize();
  return OS::sendto(this->getHandle(),
                    (const char*)buf,
                    n,
                    flags,
                    (struct sockaddr*)saddr,
                    len);
}
Esempio n. 3
0
ssize_t
SocketDgram::recv (void *buf,
              size_t n,
              InetAddr &addr,
              int flags) const {
  sockaddr* saddr = (sockaddr*)addr.getAddr();
  int addrlen = addr.getSize();

  ssize_t const status = OS::recvfrom(this->getHandle(),
                                      (char*)buf,
                                      n,
                                      flags,
                                      (sockaddr*)saddr,
                                      &addrlen);
  addr.setSize(addrlen);
  addr.setType(saddr->sa_family);
  return status;
}
Esempio n. 4
0
int
bindport(ACE_HANDLE handle, ACE_UINT32 ip_addr, int address_family) {
  InetAddr addr = InetAddr((u_short)0, ip_addr);
  return OS::bind(handle, (sockaddr*)addr.getAddr(), addr.getSize());
}