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. How to close (kill, release?) a socket, which is in FIN_WAIT_2 state?

How to close (kill, release?) a socket, which is in FIN_WAIT_2 state?

Scheduled Pinned Locked Moved C#
sysadminvisual-studiodebuggingtutorialquestion
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.
  • S Offline
    S Offline
    ShadowUz
    wrote on last edited by
    #1

    I have a client application, which uses a unmanaged dll for communicating with a server. All network-related operations are perormed inside the unmanaged dll. After a number of operations with the server, the client is running out of TCP ports. If we check the state of netwotk using 'netstat -an', we get the following result:

    ...
    TCP 192.168.11.55:56048 192.168.10.28:5000 FIN_WAIT_2
    TCP 192.168.11.55:56049 192.168.10.28:5000 FIN_WAIT_2
    TCP 192.168.11.55:56050 192.168.10.28:5000 FIN_WAIT_2
    TCP 192.168.11.55:56051 192.168.10.27:5000 FIN_WAIT_2
    TCP 192.168.11.55:56052 192.168.10.28:5000 FIN_WAIT_2
    TCP 192.168.11.55:56053 192.168.10.27:5000 FIN_WAIT_2
    TCP 192.168.11.55:56054 192.168.10.27:5000 FIN_WAIT_2
    TCP 192.168.11.55:56055 192.168.10.27:5000 FIN_WAIT_2
    TCP 192.168.11.55:56056 192.168.10.27:5000 FIN_WAIT_2
    TCP 192.168.11.55:56057 192.168.10.28:5000 FIN_WAIT_2
    TCP 192.168.11.55:56058 192.168.10.27:5000 FIN_WAIT_2
    TCP 192.168.11.55:56059 192.168.10.28:5000 FIN_WAIT_2
    TCP 192.168.11.55:56060 192.168.10.27:5000 FIN_WAIT_2
    ...

    The ports are released only after the client is closed. If I run the VS project in Debug Mode, it never runs out the ports. But, while running in Release mode, it is happening. How to release or kill those ports which are in FIN_WAIT_2 state?

    R 1 Reply Last reply
    0
    • S ShadowUz

      I have a client application, which uses a unmanaged dll for communicating with a server. All network-related operations are perormed inside the unmanaged dll. After a number of operations with the server, the client is running out of TCP ports. If we check the state of netwotk using 'netstat -an', we get the following result:

      ...
      TCP 192.168.11.55:56048 192.168.10.28:5000 FIN_WAIT_2
      TCP 192.168.11.55:56049 192.168.10.28:5000 FIN_WAIT_2
      TCP 192.168.11.55:56050 192.168.10.28:5000 FIN_WAIT_2
      TCP 192.168.11.55:56051 192.168.10.27:5000 FIN_WAIT_2
      TCP 192.168.11.55:56052 192.168.10.28:5000 FIN_WAIT_2
      TCP 192.168.11.55:56053 192.168.10.27:5000 FIN_WAIT_2
      TCP 192.168.11.55:56054 192.168.10.27:5000 FIN_WAIT_2
      TCP 192.168.11.55:56055 192.168.10.27:5000 FIN_WAIT_2
      TCP 192.168.11.55:56056 192.168.10.27:5000 FIN_WAIT_2
      TCP 192.168.11.55:56057 192.168.10.28:5000 FIN_WAIT_2
      TCP 192.168.11.55:56058 192.168.10.27:5000 FIN_WAIT_2
      TCP 192.168.11.55:56059 192.168.10.28:5000 FIN_WAIT_2
      TCP 192.168.11.55:56060 192.168.10.27:5000 FIN_WAIT_2
      ...

      The ports are released only after the client is closed. If I run the VS project in Debug Mode, it never runs out the ports. But, while running in Release mode, it is happening. How to release or kill those ports which are in FIN_WAIT_2 state?

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      Does Tom Shelton's reply on this[^] page help? /ravi

      My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

      S 1 Reply Last reply
      0
      • R Ravi Bhavnani

        Does Tom Shelton's reply on this[^] page help? /ravi

        My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

        S Offline
        S Offline
        ShadowUz
        wrote on last edited by
        #3

        Yes. I know that the server is not sending ACK to the client signaling that the socket is closed. The problem is I don't have access neither to server nor client code. The only solution I am seeing here is releasing the ports by force. In POSIX, there is a system call (linger?) to close ports. I am looking something like this for Windows, if it exists.

        R 1 Reply Last reply
        0
        • S ShadowUz

          Yes. I know that the server is not sending ACK to the client signaling that the socket is closed. The problem is I don't have access neither to server nor client code. The only solution I am seeing here is releasing the ports by force. In POSIX, there is a system call (linger?) to close ports. I am looking something like this for Windows, if it exists.

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          LingerOption[^] may help.  But methinks you'll need access to the client code (at least). /ravi

          My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

          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