CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Join Date
    Jul 2007
    Location
    Rome, Italy
    Posts
    9

    Winsock problem, probably a sign of the upcomming end of the world!!

    Ok... as you can see from the title of my post, I am pretty much desperate at this point... so I will regale you with the history of my project, and my problem... take a sit, this will take a while, if you like coffee, go make some... and if you don’t feel like reading through, skip to the end, when I summarize the whole thing.

    1 - I was asked by boss to make a "simple" chat application for one of our sites. so far so good, but, as an adobe flash (former macromedia) programmer, I was thinking to use the media server for this (if you don't know what it is 'cos you're not a flash programmer, don't worry, I didn't use it...), but my boss didn't want to use that solution, for this or that reason, so I suggested we use the flash as the client for the chat (as we intended to do any way), and use VB6, with a Winsock component, as the server for the application. My boss liked the idea, and of course he set me to program the client side (no problem) and the server side (a bit of a problem), and since my experience with VB6 is somewhat limited, I set to researching the matter, which started this whole episode.

    2 - Some time later, I had me a working client side, made up in flash, nice graphics and all, and a server side exe application, which opened up a stack of sockets (on demand), to which the clients connected and chatted happily ever after, but....

    3 - Since the server application was running on our server, and since our server, or at least this specific one (windows server 2003), is located in a server farm somewhere in the Italian wilderness, the way to do anything on the server is via remote terminal, meaning that my server application could not be run in the background, since every time the session of the remote terminal ended, it also killed the app running on the desktop... so of course I used some magic (and some NT files) to set up my application as an NT service, and like the magic that it is, all worked fine, my boss was happy, I was happy, our client was happy, and the users of the site were very happy for the new platform they have received to moan and drone about the little heart aches in their lives and so on.

    4 - Alas, this could not have prevailed... it would seem that every so often, I get an error, which my error handler simple can not handle… trying to figure out why this error occurs, find a way around it, under it, above it or on the side, or simply shutting down and restarting my application, when this error occurs, has completely taken my time since it’s started about 2 weeks ago… and that vicious error is the “10054” error, or as I like to call it, the “The connection is reset by remote side” error from HELL!!

    5 – The reason I am writing this as a story, and not as a technical question is because I have found many “answers” to this problem, but none of them seemed to work in this case, and… I will get technical in a minute or so. So I opened Google, and googled that error, number, and message, and the best I could come up with is an article by Microsoft, here – http://support.microsoft.com/kb/260018/en-us.

    6 – Now… my problem with this article by trusty old Microsoft, is that they are saying there that this error on the Winsock occurs on windows server 2000 machines (ours is 2003), and that it happens when you use a protocol type “sckUDPProtocol”, and I use “sckTCPProtocol”, and more over, that it happens in the data arrival procedure, and that it can not be “captured” by your normal error handling, where in my case, it is being reported in the “Socket_error” procedure, and what more… just before this causes my application to completely crash, I can still take some action, like actually writing a few lines into my log files, logging the error, logging some more information, I still have time (even if it’s a few milisecs) to unload the “bad” socket, redim my arrays, log some stuff for me to sort through, and only then, crash, boom, bang, the application crashes, leaving me only a “application has encountered a problem and had to close” message we all like to see when we log on to our server…

    To conclude, we had this working for us:

    1 chat client side, made in flash, using built in xml socket component. Working.
    1 server side application, made in VB6, using a stack of Winsock with the “sckTCPProtocol” protocol set to them. Working well, until…
    1 error, number 10054, description “The connection is reset by remote side” , occurring every once in a while (varies between 15 minutes to 3 days), causing the application to crash, but it would seem that only a few milliseconds after the error is raised, since after the error is raised I am still able to unload the socked that generated that error, redim some arrays, log some stuff to a txt file.

    Did any one had this problem before? Can some one tell me what could be the reason for this error, and how can get around it? When I tried to unload my application, then reopen it, and reset the variables in my project, when this specific error occurs, it actually did all that, unloaded my form, reloaded it with .show, and re initialize it (and I know this since I log these events), but still, after all that happens, my application still crashed uncontrollably.

    Thanks for listening to all this, but I am really just about to jump off our roof with this problem.


    Yuval Lahav.

  2. #2
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    Well, I don't know if this will solve the issue (and my guess is that it isn't likely unless the problem is with winsock and not the underlying technology), but my first thought would be to use CSocketPlus.

    Here are two places where you can get it:
    http://www.geocities.com/anshoku/
    http://www.programmersheaven.com/dow.../download.aspx

    Let us know how it goes.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  3. #3
    Join Date
    Jul 2007
    Location
    Rome, Italy
    Posts
    9

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    I will try it out tomorow morning (my time, Italy) and will let you know if I notice any change.

    Thanks!

    Yuval Lahav.

  4. #4
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    ^have you tried the workaround on that microsoft link? it should work.
    Busy

  5. #5
    Join Date
    Nov 2002
    Location
    Baby Land
    Posts
    646

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    I couldn't offer any help what so ever, but i would really like to hear how the story ends, or if it's ever have an ending

    And to think that I would start my own socket project in the next couple of months...

  6. #6
    Join Date
    Jul 2007
    Location
    Rome, Italy
    Posts
    9

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    Well, I did try it, and some other titbits of stuff I found on other pages, but non seem to work... it would seem that my bug is different, since they talk about a problem on windows server 2000, and we use 2003, it talks about UDP protocol, where I use TCP... it talks about an error not being catched by your normal socket error handler, where mine do, but then crashes the whole project...
    Today I will try the socket WizBang linked to, and see if I can detect any difference.

    Thanks!

  7. #7
    Join Date
    Jul 2007
    Location
    Rome, Italy
    Posts
    9

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    Well...
    I have tried implimenting the socket object WizBang has posted here, but alas, not only was I not able to get it to work with the object, it would seem the example application that come with that object generate errors and can't seem to be able to connect or, in fact, to anything else then intiate the form.

    Any one else may have a saggestion about this issue maybe?

    Thanks again.

    Yuval Lahav.

  8. #8
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    I can tell you that it isn't an exact drop-in replacement for winsock, as it has the ability to handle multiple connections. However, I have used it, so I know it does work. Perhaps if you like I can post an example for you to try. That may help you determine if the connection you have is in some way interfering with it. Or might there be permissions to set up?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  9. #9
    Join Date
    Jul 2007
    Location
    Rome, Italy
    Posts
    9

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    Well... a code exaple should would be helpfull...
    When I tried to use this in my application, the error I always recived, and could go over it, was when I was binding, or at least, trying to bind, a socket (socketarr(0) for example...) to listen on the "5005" port (which went ok), but it simple would not except anything I tried to put in for the ip, reguardless of what I did, it started ok, but on the first connection made, it crashed... when I tried to to run the example application, for some resone, it simple would not approve any sever or connection I have tried to use.
    Just to give you a heads up, in my project, I have a socket open and listening on port 5005 for incomming connections, then when I do recive a connection, I create on the fly another connection, tells the connection to listen to port 5005 as well, and bind that connection (the new one) to the specific client who made the connection request... this was simple enaugh with winsock, but I just couldn't make it work with the new controller.

    Thanks.

    Yuval Lahav.

  10. #10
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    OK, attached is a quick example. Just run it and click the button on the form. If this works then we'll have a place to start.
    Attached Files Attached Files
    Last edited by WizBang; July 27th, 2007 at 10:01 AM.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  11. #11
    Join Date
    Jul 2007
    Location
    Rome, Italy
    Posts
    9

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    Thanks for the demonstration.
    I have never used a socket to retrieve data from the Internet, be it a file for download, or an html document.
    This does not actually help me, as far as I can see with my narrow vision, with my project, since I don't need this type of action, but, at least, it shows that so far, whats in there works, and works ok.
    Now I need to figure out a way to put in that object, and make it work in my project... what I had in mine, and I will do it later, since it's the end of the working day, so I'll do this when I get home, is to post here my files, toned down of course, since there is a lot of unnecessary stuff in there, leave just the actual functional things I do, then add, commented, the new socket items, with all vars and functions in place, so you could see how I made it work with winsock, and then maybe see the error the new socket object generate, and could tell me what did I miss or done wrong?
    *(I wouldn't want to simply give you the code and ask you to do it, since if I want to become better at what I do, I need to tackle it myself... and get a little help every once in a while... no?), I will also attach with the files an exe version of my client, that will, try at least, log on to the chat server on a local connection ("localHost"), so you could run some clients and see it work.

    Laterz, and thanks again.

    Yuval Lahav.

  12. #12
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    Here we go again. Nobody will run that exe, man.
    Not one, which knownly has internet communication built in already.

  13. #13
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    What I'd like to know, is whether the crash still occurs with CSocketPlus. Since there is only one instance of the class for all sockets, perhaps the crash might be avoided even if a socket fails. If it doesn't then even if and when the initial socket error occurs, a new socket could be created, reestablishing communications.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  14. #14
    Join Date
    Jul 2007
    Location
    Rome, Italy
    Posts
    9

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    For WoF:
    Mmmm... I didn't think about that... you are probbly right.. I can, instead, simply send the swf file, and if you have a flash player installed, use that, or simply throw the file into your browser and it should work just the same...
    Will think again when talking about exe files, thanks for the heads up.

    Yuval Lahav.
    Last edited by yuvallahav; July 27th, 2007 at 01:47 PM. Reason: Adding data.

  15. #15
    Join Date
    Jul 2007
    Location
    Rome, Italy
    Posts
    9

    Re: Winsock problem, probably a sign of the upcomming end of the world!!

    This is for WizBang:
    As soon as I will have a few mins, I will remake, as I said, the application with the CSocketPlus.. first, if we could make it work, then I will publish it on our production server, and we could all hold our finguers and hope no crash occors... but if one does, we could track it down and (maybe...?) and find whats causing it.

    Yuval Lahav.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured