Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
// Attempt to read the given block of data.
struct sockaddr_in addr;
int addrLen;
addrLen = sizeof (addr);
std::vector<char> datagram (MAX_PACKET_SIZE);
long result = recvfrom (m_socket, &datagram[0], MAX_PACKET_SIZE, 0,
(struct sockaddr *) &addr, &addrLen);
// Handle any error result.
if (result == SOCKET_ERROR)
{
switch (WSAGetLastError ())
{
// Map the non-blocking result code to zero bytes written.
case WSAEWOULDBLOCK:
result = 0;
break;
// Any other result is a legitimate error.
default:
throw runtime_error ("error in recvfrom");
}
}
// Determine the host name and port number of the sender.
port = ntohs (addr.sin_port);
// Try to convert host IP address to host name.
struct hostent *hostinfo = NULL;
if (m_enableNameLookup)
{
hostinfo = gethostbyaddr ((char *) &addr.sin_addr,
sizeof (addr.sin_addr), AF_INET);
{
if (hostinfo != NULL)
{
host = hostinfo->h_name;
}
}
}
if (hostinfo == NULL)
{
ostringstream buffer;
buffer << (int) (((unsigned char *)
&addr.sin_addr) [0]);
buffer << '.';
buffer << (int) (((unsigned char *)
&addr.sin_addr) [1]);
buffer << '.';
buffer << (int) (((unsigned char *)
&addr.sin_addr) [2]);
buffer << '.';
buffer << (int) (((unsigned char *)
&addr.sin_addr) [3]);
host = buffer.str ();
}
typedef UINT_PTR SOCKET;