Jump to content
Sign in to follow this  

TCPCloseSocket not releasing socket?

Recommended Posts


The long story short is I am trying to create a test application that will connect, send a string and disconnect then repeat the process thousands of times in a short order to validate our application. The application interface takes messages from a port its listening on and then triggers further events within another system as such I want to be able to load up our system under test however I am running into a problem.

Every 16000 triggers the sends fail for a few thousand attempts as the system runs out of sockets and tries to free them up. I started writing this app in .NET but found trying to free sockets was a pain in the behind and had similar issues where windows itself runs out of available sockets, no matter how I close or dispose of them.

Here is the most simplistic code to demonstrate this issue:

for $i = 1 to 100000
    $socket = TCPConnect ( "", 13000 )
    TCPSend($socket, "test")

I basically use another application I wrote to listen and print out the incoming messages to a console window, and there are no resource leaks from what I can see using process explorer. Any help with immediate reuse of sockets would be welcome in ether AutoIT or C# thanks!

Share this post

Link to post
Share on other sites

TCPStartup() before the for loop

TCPShutdown() after the loop

Add some error handling...

If Not $socket = -1 Then





f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.