I am making a Tic Tac Toe application, with client/server. When pressing CTRL+C I have a custom handler that closes the sockets (the listening one as well), and then exits. However, if I try to run the program again, sometimes it gives an error that the port is used so it cannot bind, which lasts from several minutes (or until restart), to some seconds and sometimes it doesn't happen at all. I suspect this is a normal process, however I would like a second opinion. Also, any suggestions on how to avoid this would be appreciated!
EDIT: forgot to mention that, again SOMETIMES, killing the terminal works.