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. Repost: CSocket help needed

Repost: CSocket help needed

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminhelpquestion
3 Posts 2 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.
  • P Offline
    P Offline
    Peter Sjostrom
    wrote on last edited by
    #1

    I use a CSocket derived class with a derived CWinThread class and use CArchive with it. For some yet unknown reason Send() locks after a while of running (hours). The opened socket has communication initiated from both client and server at times, if that helps. (Server sends tiny data once per second, client sends kB data occasionally, like every 10 seconds or so, plus both sides sends an ACK byte for every command) Anyway, since I cannot find the reason of the locking, I want to get around the locked state. I want to make something from the outside and would like to have an OnIdle timer reset at intervals in the CWinThread. A parent thread will check this timer and if it isn't reset in reasonable time (seconds) the parent thread will call CancelBlockingCall() on the locked socket. Now, will this work? Isn't it illegal to call the CSocket object function from another thread? :confused:

    M 1 Reply Last reply
    0
    • P Peter Sjostrom

      I use a CSocket derived class with a derived CWinThread class and use CArchive with it. For some yet unknown reason Send() locks after a while of running (hours). The opened socket has communication initiated from both client and server at times, if that helps. (Server sends tiny data once per second, client sends kB data occasionally, like every 10 seconds or so, plus both sides sends an ACK byte for every command) Anyway, since I cannot find the reason of the locking, I want to get around the locked state. I want to make something from the outside and would like to have an OnIdle timer reset at intervals in the CWinThread. A parent thread will check this timer and if it isn't reset in reasonable time (seconds) the parent thread will call CancelBlockingCall() on the locked socket. Now, will this work? Isn't it illegal to call the CSocket object function from another thread? :confused:

      M Offline
      M Offline
      markkuk
      wrote on last edited by
      #2

      From my own experience CSockets simply aren't reliable enough for programs that need to run continuously. The best "workaround" is to use Winsock2 API directly. In my own project, I wrote a "wrapper" class to provide a CSocket-style interface so I didn't have to change the main code too much.

      P 1 Reply Last reply
      0
      • M markkuk

        From my own experience CSockets simply aren't reliable enough for programs that need to run continuously. The best "workaround" is to use Winsock2 API directly. In my own project, I wrote a "wrapper" class to provide a CSocket-style interface so I didn't have to change the main code too much.

        P Offline
        P Offline
        Peter Sjostrom
        wrote on last edited by
        #3

        *shrug*, yes, I've read this before... if I could only understand why it's locking I think we could use CSocket. We do use it in similar applications that doesn't communicate so much.

        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