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#
  4. Weird Socket behaviour after using NetworkStream

Weird Socket behaviour after using NetworkStream

Scheduled Pinned Locked Moved C#
csssysadmindebuggingregexhelp
4 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.
  • _ Offline
    _ Offline
    __DanC__
    wrote on last edited by
    #1

    I have a client / server system which uses sockets to send a receive messages. The messages are then processed on the server and a response sent back. This all works as expected most of the time but in the case of one particular message, it requires an arbitrary amount of data to follow it so I attach a NetworkStream to the Socket (specifying false to 'ownsSocket' so as not to close the socket early). Now this also works fine but some time after using the NetworkStream I get a message received twice in a single Receive call. The client has not sent it twice but it was received twice. This may happen for the message after I use the NetworkStream or after 100 successful messages after, there seems to be no pattern to it. Now this also seems to happen less and less the more debug messages I add to the application making it very hard to find the problem. The NetworkStream is closed and disposes after use. Does anyone have any idea what could be causing this? Could it just be coincidence that it seems to only happen after I use a NetworkStream?

    L 1 Reply Last reply
    0
    • _ __DanC__

      I have a client / server system which uses sockets to send a receive messages. The messages are then processed on the server and a response sent back. This all works as expected most of the time but in the case of one particular message, it requires an arbitrary amount of data to follow it so I attach a NetworkStream to the Socket (specifying false to 'ownsSocket' so as not to close the socket early). Now this also works fine but some time after using the NetworkStream I get a message received twice in a single Receive call. The client has not sent it twice but it was received twice. This may happen for the message after I use the NetworkStream or after 100 successful messages after, there seems to be no pattern to it. Now this also seems to happen less and less the more debug messages I add to the application making it very hard to find the problem. The NetworkStream is closed and disposes after use. Does anyone have any idea what could be causing this? Could it just be coincidence that it seems to only happen after I use a NetworkStream?

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      __DanC__ wrote:

      The NetworkStream is closed and disposes after use.

      Try without closing the NetworkStream.

      xacc.ide - now with TabsToSpaces support
      IronScheme - 1.0 alpha 4a out now (29 May 2008)

      _ 1 Reply Last reply
      0
      • L leppie

        __DanC__ wrote:

        The NetworkStream is closed and disposes after use.

        Try without closing the NetworkStream.

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 alpha 4a out now (29 May 2008)

        _ Offline
        _ Offline
        __DanC__
        wrote on last edited by
        #3

        Just tried that but it didn't make any difference.

        L 1 Reply Last reply
        0
        • _ __DanC__

          Just tried that but it didn't make any difference.

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

          Client maybe closing the connection?

          xacc.ide - now with TabsToSpaces support
          IronScheme - 1.0 alpha 4a out now (29 May 2008)

          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