TCP close ports

Hello,

i have a server web app (cgi) which is listening on port 8080. Connection is fine with clients, can communicate in both ways.
But when i call my cgi a second time, i get an socket error 105, which means this port is already in use (by my app) so i have to kill the pid which is listening on that port. So, do i have to close that port from my app anyhow, a simple socket.stoplistening does not do the trick…?

Are you building a Xojo Web App or is it just a console app built from the CGI template?

it’s a web app exported as cgi…
the app runs on port 9000 and the mainserversocket is listening on port 8080. I see that after +/- 5 minutes the port is closed automatically.

Edit: I have now tested in debug mode, if i reload the page in browser its the same (error 105), only if i close debugging and run it again, it works.

Btw… is tcpSocket the right choice for a communication between a desktop app to a server/browser app?

Why not use the App.HandleSpecialUrl or App.HandleUrl event?