-
February 2nd, 2011, 02:07 PM
#1
Studio 2010 async socket example
Does anyone know, why the old client-server example Chatter (=client) and ChatSrvr (=server) is removed from the Microsoft examples?
I have used this peace of code, years ago ; several times and on several computers with C++ version 6.00. It worked fine!
Now I have Studio 2010. Chatter and Chatsrvr are no longer in de example list...
I can convert the old programs when i'm loading the projects in studio 2010.
The programs even run! And the even work...but only for a couple of minutes. When the clients sends a message to the server the server is not receiving anything. (The first 20(?) or 60(?) message are received without any problem.)
I can't figure out why the socket stops. Can anyone give me a hint?
Things I have tried so far:
1) keep alive functionanlity added. The communication stops after x- time.
2) checking for something called 'blocking'. The error codes tell me the socket is NOT blocking.
3) If have simplified the data send (Class CMsg) to 'int', to avoid problems of lost pointers/static etc.
4) I have tried to let studio 2010 use .net foundation versie 3.5 instead of the new 4.0. I cann't make that work because I don't have studion 2005/2008. So I don't know if this will solve my problem.
5) I have noticed the winsock.h is now win2sock.h. I don't know the differences between them. Does anyone know winsock2 is not upwards compatible with winsock?
6) I have tried to debug the system. I'm sure the client is sending messages, but somehow the server doesn't get a on-recieve message.
7) Compiling the code with my old c++ 6.00 compiler makes perfect programms. So I think the code itself must be good. (It is microsoft example code....)
8) I have been seeking for c++ async client/server example code using archives, but I can't find anything like Chatter/Chatsrvr.
Now I don't know what to do. Using my old compiler could be an option, but it is even now no longer supported by microsoft...and I want to be up-to-date of course...!
Any suggestions are welcome to solve my problem.
-
February 2nd, 2011, 04:07 PM
#2
Re: Studio 2010 async socket example
Victor Nijegorodov
-
February 2nd, 2011, 07:15 PM
#3
Re: Studio 2010 async socket example
The default build in VS 2010 is a unicode build, whereas that for VS 6.0 was an ANSI build. Perhaps you can try an ANSI build in VS 2010, and see if that makes a difference.
@VictorN, the KB Rewrite is primarily an example of sockets in a multithreading environment, and it might be too complex for a simple chatter program, which uses asynchronous notification messages in a singly-threaded environment.
-
February 3rd, 2011, 02:06 AM
#4
Re: Studio 2010 async socket example
Originally Posted by MikeAThon
@VictorN, the KB Rewrite is primarily an example of sockets in a multithreading environment, and it might be too complex for a simple chatter program, which uses asynchronous notification messages in a singly-threaded environment.
Yes. But as tated by the author of this essay you could throw away all the multithreaded things and handle sockets in a main thread (in a thread having message pump).
Victor Nijegorodov
-
February 3rd, 2011, 10:59 AM
#5
Re: Studio 2010 async socket example
Hi Victor and Mike,
First of all, A very BIG THANK YOU for your suggestions!
I'm certainly going to try to build chatter example with unicode.
I have downloaded the sockets example and it looks good. I am really astonished about the nice commented and explained code of it! WOW, what a lot of work must that have been!
It looks like the new example works (i have a few minor problems with the built of the client, but I will first give it a try myself.)
I'm now testing it. I'm very happy.
Keep in mind, I'm an 45 old man, normally writing PLC programs for shipbuilding industrie. C++ is a bit a hobby of me. Seeing the know-how and nice peace of art the example code is, I see what a simple-little-fellow-minor-software-guy I am! (Although several ship are sealing all oceans with my lousy-simple-PLC software....)
Because of my daily work, it can take some days before I can keep You up the async socket evolution I'm experiencing now. By the way...My English sounds pretty Double-Dutch, don't You think. And last but not least.... Californie/Swiss/Netherlands...how fast is ship able to move? (Once I was Involved in a speed boat with a speed of 120 kilometres an hour on the water!)
Bye
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|