Studio 2010 async socket example
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Studio 2010 async socket example

  1. #1
    Join Date
    Feb 2011
    Posts
    2

    Lightbulb 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.

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,604

    Re: Studio 2010 async socket example

    Victor Nijegorodov

  3. #3
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,553

    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.

  4. #4
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,604

    Re: Studio 2010 async socket example

    Quote Originally Posted by MikeAThon View Post
    @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

  5. #5
    Join Date
    Feb 2011
    Posts
    2

    Wink 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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center