Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Weird situation with WinSock

Weird situation with WinSock

Scheduled Pinned Locked Moved C / C++ / MFC
testingdebuggingbeta-testinghelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hxhl95
    wrote on last edited by
    #1

    Alright, I've ran into a problem that I'm really confused over: I'm writing a simple mail client. It runs fine on my computer (Windows XP, SP2). However, when ran on a Vista machine, it crashes. Not as in BSOD-crash, it's more like the whole system just freezes over. A friend of mine, who was testing it on her vista machine, she says that everything just freezes (including the mouse) and the few times she had music on, *the last few times *i had musci on *but not this time *and it like.. *Stutters *in that spot I managed to trace it down to here:

    MessageBox(NULL,"got here 1","okay",MB\_OK);
    
    closesocket(hSocket);
    hSocket = NULL;
    
    MessageBox(NULL,"got here 3","okay",MB\_OK);
    

    The first msgbox shows, but the second doesn't. (friend of mine isn't exactly computer-savvy, so I put the messageboxs in there so she could test the app). I'm really stumped by this, because it works fine on XP. What does Vista change that doesn't allow the proper disconnection and closing of a socket? If it changes anything, this is all happening in a seperate thread, started by a call to AfxBeginThread inside a WH_KEYBOARD_LL callback function. But that shouldn't make a difference, should it? If any more info is needed, just ask. It's a rather large piece of code, so it's hard for me to describe everything that's going on. Thanks in advance. :)

    C D 2 Replies Last reply
    0
    • H hxhl95

      Alright, I've ran into a problem that I'm really confused over: I'm writing a simple mail client. It runs fine on my computer (Windows XP, SP2). However, when ran on a Vista machine, it crashes. Not as in BSOD-crash, it's more like the whole system just freezes over. A friend of mine, who was testing it on her vista machine, she says that everything just freezes (including the mouse) and the few times she had music on, *the last few times *i had musci on *but not this time *and it like.. *Stutters *in that spot I managed to trace it down to here:

      MessageBox(NULL,"got here 1","okay",MB\_OK);
      
      closesocket(hSocket);
      hSocket = NULL;
      
      MessageBox(NULL,"got here 3","okay",MB\_OK);
      

      The first msgbox shows, but the second doesn't. (friend of mine isn't exactly computer-savvy, so I put the messageboxs in there so she could test the app). I'm really stumped by this, because it works fine on XP. What does Vista change that doesn't allow the proper disconnection and closing of a socket? If it changes anything, this is all happening in a seperate thread, started by a call to AfxBeginThread inside a WH_KEYBOARD_LL callback function. But that shouldn't make a difference, should it? If any more info is needed, just ask. It's a rather large piece of code, so it's hard for me to describe everything that's going on. Thanks in advance. :)

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Did you try it on more than one Vista machines? Does it crash at the same spot on every vista computers? You mentioned that it is happeneding in a separate thread, so, could it be a synchronization error? I mean, synchronization errors tend to be different depending on a lot of things, for example we had such error(s) that would never pop up on a single core muchine but they would happen almost every time on dual core systems, also they can depend on timings, for example you could have such an error that doesn't pop up at first but if you run winamp and start playing your favourite music then it does because if the computer has more things to do then your process/threads get less CPU time and then somethings that before did not happen simulteniously before will happen now and cause the problem... Also, are you sure your hSocket is valid?

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <

      H 1 Reply Last reply
      0
      • C Code o mat

        Did you try it on more than one Vista machines? Does it crash at the same spot on every vista computers? You mentioned that it is happeneding in a separate thread, so, could it be a synchronization error? I mean, synchronization errors tend to be different depending on a lot of things, for example we had such error(s) that would never pop up on a single core muchine but they would happen almost every time on dual core systems, also they can depend on timings, for example you could have such an error that doesn't pop up at first but if you run winamp and start playing your favourite music then it does because if the computer has more things to do then your process/threads get less CPU time and then somethings that before did not happen simulteniously before will happen now and cause the problem... Also, are you sure your hSocket is valid?

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <

        H Offline
        H Offline
        hxhl95
        wrote on last edited by
        #3

        Again, sorry for the vagueness. No, I haven't tried it on more than 1 Vista machines, and I doubt it's a synchronization error. All the thread does is create an email header and sends it, while the main thread is open for the UI. Aside from the 4 variables passed to the thread at the start, the thread doesn't even use any of the variables used in the main thread. Yes, I'm sure my hSocket is valid, as I seem to be able to send emails using it. I'm going to try it on some more vista machines today, thanks for the suggestion. :)

        1 Reply Last reply
        0
        • H hxhl95

          Alright, I've ran into a problem that I'm really confused over: I'm writing a simple mail client. It runs fine on my computer (Windows XP, SP2). However, when ran on a Vista machine, it crashes. Not as in BSOD-crash, it's more like the whole system just freezes over. A friend of mine, who was testing it on her vista machine, she says that everything just freezes (including the mouse) and the few times she had music on, *the last few times *i had musci on *but not this time *and it like.. *Stutters *in that spot I managed to trace it down to here:

          MessageBox(NULL,"got here 1","okay",MB\_OK);
          
          closesocket(hSocket);
          hSocket = NULL;
          
          MessageBox(NULL,"got here 3","okay",MB\_OK);
          

          The first msgbox shows, but the second doesn't. (friend of mine isn't exactly computer-savvy, so I put the messageboxs in there so she could test the app). I'm really stumped by this, because it works fine on XP. What does Vista change that doesn't allow the proper disconnection and closing of a socket? If it changes anything, this is all happening in a seperate thread, started by a call to AfxBeginThread inside a WH_KEYBOARD_LL callback function. But that shouldn't make a difference, should it? If any more info is needed, just ask. It's a rather large piece of code, so it's hard for me to describe everything that's going on. Thanks in advance. :)

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          hxhl95 wrote:

          If it changes anything, this is all happening in a seperate thread, started by a call to AfxBeginThread inside a WH_KEYBOARD_LL callback function. But that shouldn't make a difference, should it?

          Introducing multiple threads will always make a difference. Race conditions, sharing of resources, deadlocks, and context switches are just some of the things that come into play above and beyond the normal stuff.

          "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups