Skip to Content
Programming 2D Games
book

Programming 2D Games

by Charles Kelly
June 2012
Beginner
438 pages
15h 26m
English
A K Peters/CRC Press
Content preview from Programming 2D Games
38312.9. Closing a Socket
ret = recvfrom(sock, data, readSize, 0, (SOCKADDR *)&remoteAddr,
&remoteAddrSize);
if (ret == SOCKET_ERROR) {
status = WSAGetLastError();
if ( status != WSAEWOULDBLOCK) // Don't report WOULDBLOCK
// error
return ((status << 16) + NET_ERROR);
ret = 0; // Clear SOCKET_ERROR
// If TCP connection did graceful close
} else if(ret == 0 && type == CONNECTED_TCP)
// Return Remote Disconnect error
return ((REMOTE_DISCONNECT << 16) + NET_ERROR);
if (ret)
// IP of sender
strncpy_s(senderIP, IP_SIZE, inet_ntoa(remoteAddr.sin_addr),
IP_SIZE);
size = ret; // Number of bytes read, may be 0
}
return NET_OK;
}
Listing 12.6(e). e ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning 3D Game Programming

Beginning 3D Game Programming

Tom Miller

Publisher Resources

ISBN: 9781466508705