Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi Everyone,

I'm implementing asynchonous socket programming in (C++, winsock, TCP/IP, based on this example Chat Client Server[^]) at the moment (for data streaming) and am running into problems with missing data when I run the code over a network rather than locally (I only seem to recieve a packet every 0.7s, despite sending them every 0.1s).

Its a pain to ask my colleague to run my client code on his computer everytime I want to debug, so I wonder if it's possible to run my client and server on the same machine but to send the message over a physical network & router, to re-create the same problem? So, instead of my client connecting to 127.0.0.1, I actually connect it to my IP address and the message goes through my phsycial hub.

Is this possible? Or am I barking up the wrong tree? :confused:

Thanks,

Ad
Posted
Comments
Manfred Rudolf Bihy 17-Jan-11 14:50pm    
Good question! 5+

In my experience, running your client in a virtual machine on the same computer as the server lets you simulate real-world client-server environments very realistically. Our company used VMWare's and Microsoft's virtualization products for debugging and in QA; both worked very well for our purposes. It looks like this approach may work in your case as well - the code path inside the framework and OS will be the same as in a non-local client-server scenario, except the packets will not travel to the router and back.
 
Share this answer
 
Comments
Espen Harlinn 17-Jan-11 13:13pm    
5+ Good answer
Manfred Rudolf Bihy 17-Jan-11 14:50pm    
Good call! 5+
Sergey Alexandrovich Kryukov 17-Jan-11 18:17pm    
Good - my 5.
Virtual machine might be an answer here; but I advice that get another dedicated machine for testing from your employers since it will be far better to test on actual physical layer than any kind of simulation.

On a second thought, there is one more thing you can do,
1. Get another network card for your machine
2. Connect it to a switch and assign IP address
3. You will get two different IP addresses on your machine
4. Run server on one IP and client on another and connect them.
 
Share this answer
 
v2
Comments
Espen Harlinn 17-Jan-11 13:11pm    
5+ Nice and easy
HimanshuJoshi 17-Jan-11 13:35pm    
Thanks Espenn
Manfred Rudolf Bihy 17-Jan-11 14:49pm    
Good idea! 5+
HimanshuJoshi 17-Jan-11 15:26pm    
Thanks Manfred R. Bihy
Sergey Alexandrovich Kryukov 17-Jan-11 19:28pm    
Very useful list of options - my 5.
Thank you,
--SA
A few pointers that you may or may not already know:

Remote debugging can be set up by running msvsmon.exe from C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\<platform>\msvsmon.exe on the remote computer or VM. This is in the 64-bit Program Files on a 64-bit computer, then in the debugging page of the project properties select Remote Windows Debugger from the drop-down list

Packets are generally concatenated together, hence you might be receiving 7 packets every 0.7 seconds if it takes your code that long to get back around to checking.
 
Share this answer
 
Comments
ad_robot 18-Jan-11 5:36am    
"Packets are generally concatenated together...", ah, interesting, I'll have to look into this. Thanks for the tips.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900