PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Reusing socket programming for Win32/PocketPC

Hi,

I am writing a 2D Space shooting game using Visual C++ and the Gapidraw library. My IDE is VS2005.

My idea for this game is to be compatible with Windows and Pocket PC devices.

So far everything is going perfect. Now I would like to add some code that uploads high scores to a database. I need to write a basic TCP/IP client connection but I'm not sure how to make it compatible with both systems.

Is that possible or I need to have a different code for each one?

Thanks
Just use the standard Berkeley socket API. Besides a unicode conversion here or there, the same code will build right up for both platforms.

Dan East
Here are a bunch of examples:
http://www.sockaddr.com/ExampleSourceCode.html

One thing I noticed is that for the desktop you link using wsock32.lib, but for WM using winsock.lib. Your code doesn't change at all though.

-John
If you only need to submit a few variables via a querystring, use the URLDownloadToCacheFile function, its much easier than messing with sockets.
Thanks a lot for your help!

I made some testing with those examples and it seems to work for both platforms.

Regards
mm40 wrote:If you only need to submit a few variables via a querystring, use the URLDownloadToCacheFile function, its much easier than messing with sockets.


Thanks for your reply.

I found one example of that function here http://www.codeguru.com/Cpp/I-N/interne ... .php/c3467
but it doesn't seem to be very simple because you need to create callback functions for the progress and other stuff.

Do you have by any change a simple example that uses that?

Thanks
The callbacks are optional

Code:

USES_CONVERSION;
TCHAR path[MAX_PATH];

HRESULT hr = URLDownloadToCacheFile(NULL, A2T(url), path, MAX_PATH, 0, NULL);
if(FAILED(hr))
return hr;

hr = ReadFile(T2A(path), (byte*)data, size);
if(FAILED(hr))
return hr;

DeleteFile(path);
Thanks for the example.

I have tested on my desktop and on my pda and it works ok for the desktop, however it fails on the PDA.

It's weird because if I use regular sockets it works ok on the PDA.

Just in case somebody wants to test it, here is the code

Code:


TCHAR file[MAX_PATH];

HRESULT hr = URLDownloadToCacheFile(NULL, _T("http://www.sockaddr.com/ExampleSourceCode.html"), file, MAX_PATH, 0, NULL);

if(FAILED(hr))
{
return hr;
}