Games for Windows and the DirectX SDK blog

Technical tips, tricks, and news about game development for Microsoft platforms including desktop, Xbox, and UWP


Project maintained by walbourn Hosted on GitHub Pages — Theme by mattgraham
Home | Posts by Tag | Posts by Month

Windows Networking

networking

Originally posted to Chuck Walbourn's Blog on MSDN,

Over the past few years at game conferences we’ve talked a lot about the Xbox LIVE service and the many great opportunities on Xbox 360, Windows, and Windows Phone using it. What we’ve talked less about in these venues are best practices for those writing their own multiplayer clients and servers. While the glory days of DirectPlay are long past (it was a great technology when you had to contend with head-to-head modem play, direct serial connections, TCP/IP over modem, IPX/SPX, and TCP/IP all at once), there’s more to Windows networking than WinSock 2.

Windows Firewall

The Windows Firewall included in Windows XP Service Pack 2 was a big part of the network security work for this release, and this firewall is still in place in current versions of Windows. For pure clients, there’s not much to do but it does have impact on servers and peer-to-peer communications.

Windows Firewalls for Game Developers (DirectX SDK)

Games, Firewalls and Microsoft Windows XP SP2 (Meltdown 2004 presentation in the Windows Track)

Related FirewallInstallHelper sample

IPV6

Microsoft has invested heavily in preparing for the IPV6 Internet, including a IPV4/IPV6 dual-stack in the current generation of operating systems even including Windows XP Service Pack 3. While most games and game servers today are IPV4 only, moving your code to be ‘IP-agnostic’ is a good way to prepare for a transition to IPV6.</a>

Peer-to-peer Networking

Beyond just investing in IPV6, Microsoft has also built some technologies to improve peer-to-peer NAT traversal (called Teredo) and peer-to-peer name resolution (Peer Name Resolution Protocol aka PNRP). If you want to learn more, check out these resources:

Peer to Peer Connectivity & Communications</a> (Meltdown 2005 presentation in the Windows Track)

InternetGetConnectedState

This legacy API dates back to Internet Explorer 4 and is used by some games to check for an active Internet connection. There is a much improved API for this available starting with Windows Vista called the Network List Manager API. A sample of using NLM is attached to the post.

If you still need a Windows XP fallback (i.e. the COM creation in the sample code will always fail), then you should remember that just because InternetGetConnectedState returns TRUE does not mean you have an active internet connection, You need to follow it up with an attempt to reach a known Internet location (via InternetOpen and InternetOpenUrl). If you are curious about how Windows 7 does it’s “network connection available” test, check out this article.

netdetectvista.cpp