I don't see anything about a popup alert dialog in your original post. All you said is you want to to close the socket and be alerted when it tries to open. I gave you a simple script that would do just that.

What your now asking for would require rewriting the /sockopen command.