Reputation: 83
This might be a really ignorant question, but I have a need to create a socket when a person enters my application, use that socket for multiple operations, then dispose of it as soon as the person leaves the page. I would immediately think of using the session array, but I'm not sure that would be the best for performance, but it may be my only option.
Any help would be greatly appreciated. Thanks in advance!
EDIT: Web Sockets would be ideal, but, correct me if I'm wrong, I don't own the socket server so I wouldn't be able to connect directly to it. My main goal is to interact with a proprietary socket server, while keeping the context of the conversation alive (keep the socket open).
I can fit everything in on one page, but need to be able to interact with the user.
Upvotes: 1
Views: 1634
Reputation: 25139
If you need to establish a socket connection from the client, you will need to use Web Sockets. These are very new and are only supported in a few browsers.
If you need to keep a HTTP connection open, you can do that using AJAX, but only as long as the user stays on a single page. You also may have to periodically close the connection and open a new one as many browsers will time out the connection after a short time.
Upvotes: 3