本文整理汇总了C++中Host::setHost方法的典型用法代码示例。如果您正苦于以下问题:C++ Host::setHost方法的具体用法?C++ Host::setHost怎么用?C++ Host::setHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host::setHost方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: receiveCharArray
AbstractSocket::Status UdpSocket::receiveCharArray(char** str, Host& peer)
{
*str = new char[MaxDatagramSize];
struct sockaddr_in from;
int dataRead;
int len = sizeof(from);
if ((dataRead = recvfrom(m_socketfd, *str, MaxDatagramSize, 0, reinterpret_cast<sockaddr*>(&from), reinterpret_cast<socklen_t*>(&len))) == -1)
return getStatus();
peer.setHost(from);
return Done;
}
示例2: receiveString
AbstractSocket::Status UdpSocket::receiveString(string& str, Host& peer)
{
char* buffer = new char[MaxDatagramSize];
struct sockaddr_in from;
int dataRead;
int len = sizeof(from);
if ((dataRead = recvfrom(m_socketfd, buffer, MaxDatagramSize, 0, reinterpret_cast<sockaddr*>(&from), reinterpret_cast<socklen_t*>(&len))) == -1)
return getStatus();
peer.setHost(from);
str.assign(buffer, dataRead);
return Done;
}
示例3: getStatus
AbstractSocket::Status UdpSocket::receiveInt32(int32& i, Host& peer)
{
int32 buffer;
struct sockaddr_in from;
int dataRead;
int len = sizeof(from);
if ((dataRead = recvfrom(m_socketfd, &buffer, sizeof(int32), 0, reinterpret_cast<sockaddr*>(&from), reinterpret_cast<socklen_t*>(&len))) == -1)
return getStatus();
peer.setHost(from);
i = ntohl(buffer);
return Done;
}
示例4: receiveFrame
AbstractSocket::Status UdpSocket::receiveFrame(Frame &f, Host& peer)
{
uint32 size;
struct sockaddr_in from;
uint32 dataRead;
int len = sizeof(from);
char *buffer;
buffer = new char[MaxDatagramSize];
if ((dataRead = recvfrom(m_socketfd, buffer, MaxDatagramSize, 0, reinterpret_cast<sockaddr*>(&from), reinterpret_cast<socklen_t*>(&len))) == -1)
return getStatus();
f.setData(buffer, dataRead);
peer.setHost(from);
return Done;
}