本文整理汇总了C++中Host::getHost方法的典型用法代码示例。如果您正苦于以下问题:C++ Host::getHost方法的具体用法?C++ Host::getHost怎么用?C++ Host::getHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host::getHost方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getStatus
AbstractSocket::Status UdpSocket::sendInt32(const int32& i, Host& h)
{
struct sockaddr_in peer;
int32 toSend = htonl(i);
if (m_socketfd == -1)
if ((m_socketfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
return getStatus();
peer = h.getHost();
if (sendto(m_socketfd, &toSend, sizeof(int32), 0, reinterpret_cast<sockaddr*>(&peer), sizeof(peer)) == -1)
return getStatus();
return AbstractSocket::Done;
}
示例2: sendCharArray
AbstractSocket::Status UdpSocket::sendCharArray(const char* str, const size_t& s, Host& h)
{
struct sockaddr_in peer;
if (m_socketfd == -1)
if ((m_socketfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
return getStatus();
peer = h.getHost();
if (sendto(m_socketfd, str, s, 0, reinterpret_cast<sockaddr*>(&peer), sizeof(peer)) == -1)
return getStatus();
return AbstractSocket::Done;
}
示例3: sendString
AbstractSocket::Status UdpSocket::sendString(const string& str, Host& h)
{
struct sockaddr_in peer;
const char* data = str.c_str();
if (m_socketfd == -1)
if ((m_socketfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
return getStatus();
peer = h.getHost();
if (sendto(m_socketfd, data, str.length(), 0, reinterpret_cast<sockaddr*>(&peer), sizeof(peer)) == -1)
return getStatus();
return AbstractSocket::Done;
}
示例4: sendFrame
AbstractSocket::Status UdpSocket::sendFrame(Frame& f, Host& h)
{
struct sockaddr_in peer;
if (m_socketfd == -1)
if ((m_socketfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
return getStatus();
peer = h.getHost();
uint32 size = f.getSize();
if(size > MaxDatagramSize)
return UdpDatagramTooBig;
int r = sendto(m_socketfd, f.getData(), size, 0, reinterpret_cast<sockaddr*>(&peer), sizeof(peer));
if(r<0)
return getStatus();
return Done;
}