Closing sockets when exiting
Posted: Mon Nov 11, 2013 7:38 am
I have a problem with my standalone not actually exiting. It seems the window goes away, but I still see the process in the Windows 7 Task Manager. The issue has something to do with closing all the sockets. The stack has only one card, and the card script does an
That all works fine, the socket sends data back and forth. In the closeCard handler of the card, I have
So here is the weird thing. When I build my standalone (on Windows), if the answer command is commented out, then the process never quits. If the answer command is uncommented, then it shows the proper message AND the process quits! There is only one socket that is being closed, it is the 7777 socket that was opened for connections initially. ( I have closed all the other sockets in use before we get to this point).
Riddle me that, Batman!
Could it be that the close socket command is asynchronous, and only completes later after trying to fire a socketClosed message to a non-existant card? But since the card is already gone, it just hangs? Seems weird because the answer command is before the close socket command and should not really hold up the application after it is dismissed.
Code: Select all
on opencard
accept connections on port 7777 with message sClientConnected
end opencard
That all works fine, the socket sends data back and forth. In the closeCard handler of the card, I have
Code: Select all
on closecard
repeat for each line tSocket in the opensockets
--answer "Closing socket" && tSocket
close socket tSocket
end repeat
end closecard
Riddle me that, Batman!
Could it be that the close socket command is asynchronous, and only completes later after trying to fire a socketClosed message to a non-existant card? But since the card is already gone, it just hangs? Seems weird because the answer command is before the close socket command and should not really hold up the application after it is dismissed.