Example #1
0
int		SocketConnector::connect(SocketStream &stream, InetAddr const &addr, size_t)
{
	Handle ret = ::connect(_handle, addr, addr.getSize());
	if (ret == INVALID_HANDLE)
		return -1;
	stream.setHandle(_handle);
	return 0;
}
Example #2
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;
}
Example #3
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);
}
Example #4
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;
}
Example #5
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());
}