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. a socket problem

a socket problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpsysadminquestion
9 Posts 6 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.
  • T Offline
    T Offline
    tyr2000
    wrote on last edited by
    #1

    i wrote a c/s app. the client sends a DWORD to the server.it runs no error,but the DWORD sent doesn't equal to the DWORD received some times ,how it happens?

    R C L T 4 Replies Last reply
    0
    • T tyr2000

      i wrote a c/s app. the client sends a DWORD to the server.it runs no error,but the DWORD sent doesn't equal to the DWORD received some times ,how it happens?

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      Someone ate a byte or two on the way? Seriously though, you need to be more specific than that. Read the guidelines ("How to get an answer to your question") which is on top of this forum, please.

      It is a crappy thing, but it's life -^ Carlo Pallini

      1 Reply Last reply
      0
      • T tyr2000

        i wrote a c/s app. the client sends a DWORD to the server.it runs no error,but the DWORD sent doesn't equal to the DWORD received some times ,how it happens?

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        Inputs, outputs...We have no elements, Watson! :-D

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        1 Reply Last reply
        0
        • T tyr2000

          i wrote a c/s app. the client sends a DWORD to the server.it runs no error,but the DWORD sent doesn't equal to the DWORD received some times ,how it happens?

          L Offline
          L Offline
          luxiaokang
          wrote on last edited by
          #4

          maybe there is something about network byte order!

          L 1 Reply Last reply
          0
          • L luxiaokang

            maybe there is something about network byte order!

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            The network packets contain: - packet information, which must obey the byte order specified in the standards specification; the drivers and network protocols are there to take care of that on both ends. - the actual user-defined data (the "payload"); here it is up to the user how the bytes have to be interpreted. As the OP said it works often and fails sometimes, I don't think a byte ordering mistake was made. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


            F 1 Reply Last reply
            0
            • L Luc Pattyn

              The network packets contain: - packet information, which must obey the byte order specified in the standards specification; the drivers and network protocols are there to take care of that on both ends. - the actual user-defined data (the "payload"); here it is up to the user how the bytes have to be interpreted. As the OP said it works often and fails sometimes, I don't think a byte ordering mistake was made. :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


              F Offline
              F Offline
              fanronghua
              wrote on last edited by
              #6

              Please upload you code............

              1 Reply Last reply
              0
              • T tyr2000

                i wrote a c/s app. the client sends a DWORD to the server.it runs no error,but the DWORD sent doesn't equal to the DWORD received some times ,how it happens?

                T Offline
                T Offline
                tyr2000
                wrote on last edited by
                #7

                o!! I find the problem at last! It is a Multithread problem, one data struction used in multithread without protection, data was dirty. :)

                L 1 Reply Last reply
                0
                • T tyr2000

                  o!! I find the problem at last! It is a Multithread problem, one data struction used in multithread without protection, data was dirty. :)

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  a dirty DWORD??? you mean you didn't correctly make a local copy then, it is too small to not update atomically. :)

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


                  T 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    a dirty DWORD??? you mean you didn't correctly make a local copy then, it is too small to not update atomically. :)

                    Luc Pattyn [Forum Guidelines] [My Articles]


                    The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


                    T Offline
                    T Offline
                    tyr2000
                    wrote on last edited by
                    #9

                    my multithread app used some threads which have a socket parameter sent in,before the parameter being used ,another thread make it dirty. this is what happened in my app.

                    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