socket not closing even after the listening app has terminated?!
-
hi! i have a very weird problem: i have an app which listens for connections, and once a client connects it starts anothter app, now if the main listening app terminates but app2 is still running then the port isnt released and when the main app starts up again and try to bind to the port it fails (port already in use). the port is first released when app2 or all of its child processes has terminated, but these processes has nothing to with the main app, so why isnt port released after the main app has been terminated?
-
hi! i have a very weird problem: i have an app which listens for connections, and once a client connects it starts anothter app, now if the main listening app terminates but app2 is still running then the port isnt released and when the main app starts up again and try to bind to the port it fails (port already in use). the port is first released when app2 or all of its child processes has terminated, but these processes has nothing to with the main app, so why isnt port released after the main app has been terminated?
After little more investigation with process hacker (Process Hacker/[^]) i see that the apps started from the main listening app and there child process gets the handle to the named pipes and somthing called \device\afd that main app has created, if i close those handles then the port is released, if i dont then the main app actuallty keeps running and listening on that port according to process hacker but doenst respond to incoming connections. :wtf: so the main app, after its terminated doenst show upp in process list/taskmanager or netstat tool but shows up as UnknownpProcess in process hackers "network connections" listening on the port??:confused: How can i fix this? This is how the app currently works... My App --> starts app2 and creates pipes. Now if my app gets terminated then app 2 is also terminated, but i have no control of which apps app2 might start and they are not terminated once app2 gets terminated so they keeps the handle to named pipes and (mainly)device\afd and keeps the port busy?
-
After little more investigation with process hacker (Process Hacker/[^]) i see that the apps started from the main listening app and there child process gets the handle to the named pipes and somthing called \device\afd that main app has created, if i close those handles then the port is released, if i dont then the main app actuallty keeps running and listening on that port according to process hacker but doenst respond to incoming connections. :wtf: so the main app, after its terminated doenst show upp in process list/taskmanager or netstat tool but shows up as UnknownpProcess in process hackers "network connections" listening on the port??:confused: How can i fix this? This is how the app currently works... My App --> starts app2 and creates pipes. Now if my app gets terminated then app 2 is also terminated, but i have no control of which apps app2 might start and they are not terminated once app2 gets terminated so they keeps the handle to named pipes and (mainly)device\afd and keeps the port busy?