本文整理汇总了C++中SocketAddress::GetAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketAddress::GetAddress方法的具体用法?C++ SocketAddress::GetAddress怎么用?C++ SocketAddress::GetAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketAddress
的用法示例。
在下文中一共展示了SocketAddress::GetAddress方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
bool
SocketDescriptor::Connect(SocketAddress address)
{
assert(address.IsDefined());
return ::connect(Get(), address.GetAddress(), address.GetSize()) >= 0;
}
示例2: Connect
bool SocketImpl::Connect(const SocketAddress& address, const std::chrono::seconds& timeout /*= std::chrono::seconds(0)*/)
{
if (INVALID_SOCKET == m_sockfd)
Init(AF_INET);
if (timeout.count() > 0)
SetBlocking(false);
bool bResult = false;
do
{
if (SOCKET_ERROR == connect(m_sockfd, address.GetAddress(), address.GetLength()))
{
if (timeout.count() == 0)
break;
int err = WSAGetLastError();
if (WSAEINPROGRESS != err
&& WSAEWOULDBLOCK != err
&& WSAEISCONN != err)
break;
if (!Poll(timeout, SELECT_READ | SELECT_WRITE | SELECT_ERROR))
break;
if (GetSocketError() != 0)
break;
}
bResult = true;
} while (0);
if (timeout.count() > 0)
SetBlocking(true);
return bResult;
}
示例3: Bind
bool SocketImpl::Bind(const SocketAddress& address, bool bReuse /*= false*/)
{
if (INVALID_SOCKET == m_sockfd)
Init(AF_INET);
if (bReuse)
SetReuseAddress(true);
return bind(m_sockfd, address.GetAddress(), address.GetLength()) != SOCKET_ERROR;
}
示例4: Bind
int GenericSocket::Bind(SocketAddress & sa)
{
sockaddr dir;
sa.GetAddress(dir);
int err = bind(sock, &dir, sizeof(sockaddr));
if (err == -1)
{
SocketTools::MostrarError("Error en GenericSocket::Bind");
}
return err;
}
示例5: SendTo
int SocketImpl::SendTo(const char* buffer, int length, const SocketAddress& address, int flags /*= 0*/)
{
assert(INVALID_SOCKET != m_sockfd);
return sendto(m_sockfd, buffer, length, flags, address.GetAddress(), address.GetLength());
}
示例6:
ssize_t
SocketDescriptor::Write(const void *buffer, size_t length,
SocketAddress address)
{
int flags = 0;
#ifdef HAVE_POSIX
flags |= MSG_DONTWAIT;
#endif
#ifdef __linux__
flags |= MSG_NOSIGNAL;
#endif
return ::sendto(Get(), (const char *)buffer, length, flags,
address.GetAddress(), address.GetSize());
}
示例7: bind
bool
SocketDescriptor::Bind(SocketAddress address)
{
return bind(Get(), address.GetAddress(), address.GetSize()) == 0;
}