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. A question about closing socket

A question about closing socket

Scheduled Pinned Locked Moved C#
questionsysadmintestingbeta-testing
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.
  • T Offline
    T Offline
    tiwal
    wrote on last edited by
    #1

    Hello , I am testing a very simple client/server socket application, using an asynchronous socket model. When I am closing a connection on behalf of client side, I am first calling the Shutdown(..both) method on the socket and then the Close () method. I am expecting a zero-length packet received on the server side , to signal the connection closing on the client side,and after this I call the Close () on the socket on the server side. The truth is, I receive more than one zero-length packet on the server when I shut down the connection on the client side . Why does it happen ? And how can it be since on the first zero-length packet I receive on the server , I close the server socket and no more packets should be received anymore ?

    P 1 Reply Last reply
    0
    • T tiwal

      Hello , I am testing a very simple client/server socket application, using an asynchronous socket model. When I am closing a connection on behalf of client side, I am first calling the Shutdown(..both) method on the socket and then the Close () method. I am expecting a zero-length packet received on the server side , to signal the connection closing on the client side,and after this I call the Close () on the socket on the server side. The truth is, I receive more than one zero-length packet on the server when I shut down the connection on the client side . Why does it happen ? And how can it be since on the first zero-length packet I receive on the server , I close the server socket and no more packets should be received anymore ?

      P Offline
      P Offline
      Philip Stuyck
      wrote on last edited by
      #2

      Closing a socket basically means that you will not use that socket for sending anymore. So you can still receive on it. This is why it is called a half close. Don't know why you see more than one zero packet sizes. This should occur only once because it is an indication that the peer side has closed its connection.

      T 1 Reply Last reply
      0
      • P Philip Stuyck

        Closing a socket basically means that you will not use that socket for sending anymore. So you can still receive on it. This is why it is called a half close. Don't know why you see more than one zero packet sizes. This should occur only once because it is an indication that the peer side has closed its connection.

        T Offline
        T Offline
        tiwal
        wrote on last edited by
        #3

        Thank you Philip, by now I think I have found the problem.... probably it was caused by the fact that , inadvertedly, I was calling beginReceive() more than once, before calling the corresponding endReceive() for each beginReceive() . In effect as I fixed this error it seems it doesn't happen anymore. Thank you anyway for your support. Leo

        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