XBOX Debugging Client/Server package
What is it?
This is a client/server package that will let you send send debug messages from
your XBOX to your computer via TCP/IP
This package can also serve as a beginner's guide to the XBOX networking API
and to network programming for Windows.
How is this useful?
When your program is crashing on you and you don't know where or why, you can
use this package to provide instantaneous messaging from the XBOX to your
Another way of doing essentially the same thing is to write debugging
information to a file on the XBOX HD and then use EvolutionX to transfer that
file back to your computer where you can read it. This debugging package is
just an easier way to see your results.
There is also a WaitKey() command that will make the XBOX program wait until
you have pressed a key on your computer. It will transfer that character
back to the XBOX and you could use it to branch to a different code location.
This means that you could step through your code and branch off to different
sections depending on what key you press on your computer.
How do I use it?
Put the debugclient.cpp and debugclient.h files into your project directory.
In your project, make sure you've also included the following files in your
These files are located in the Samples\xbox\common\src directory.
You'll also need to go to your project settings and include the
xonlined.lib (debug) or xonline.lib (release) library file.
Once you've done that, you can use the package in the following manner:
CDebugClient m_debugClient ;
//Establish a connection to 192.168.123.111 on port 7654.
//The "1" parameter means that we want this connection to block.
//Specify "0" instead to get a nonblocking connection.
//Nonblocking connections won't wait to send/receive
//data, so calls to Recv and Send return immediately.
if ( m_debugClient.Init( "192.168.123.111", 7654, 1 ) == 0 )
//send the string "debug message\r\n" to the debug server.
//15 is the length of the string "debug message\r\n"
if ( m_debugClient.Send( "debug message\r\n", 15 ) == 0 )
//this code will make the xbox wait until you've pressed a key on your
//computer. Then it will branch depending on what key you entered.
switch ( m_debugClient.WaitKey( ) )
case 'T' : executeProc1() ; break ;
case 'D' : executeProc2() ; break ;
default : break ;
//close the connection, stop networking
That's really all there is to it.
To make it work, first run debugserver.exe on your computer. This will
start listening for connections on port 7654. (debugserver.exe source
code is included, so you can change that port value to whatever you want
or add code to grab that setting from the registry, ini file, command line,
whatever.) Now that debugserver.exe is running on your computer, you can
start up your XBOX program. When the Init function is executed, a message
will show up on your debugserver window saying that the connection was
established. It might not show up right away, so give it a few seconds.
From then on, the debugserver window will display the data you send
via the Send() functions.
The DebugClient class is simply a helper class which encapsulates some
functionality from the XBSocket class. There's lots of other useful
stuff in there including binding/listening so that you can turn your
XBOX into network server.
The debugserver application shows you how to create client/server
programs on your computer using TCP4U. TCP4U is an excellent wrapper
around the WINSOCK API that really facilitates network programming.
With these two pieces of the puzzle and your own initiative, you can
do things like XBOX FTP/HTTP servers, gaming between XBOX and computers,