I have written a php script, which connects to facebook chat via tcp socket. My questions are:

1. How to keep the socket alive even when the php script is ended? I want other php file to communicate with facebook XMPP server via this socket? I have tried to save the socket as a session variable, but it did not work.
2. I tried to use pfsockopen instead of socket\_create, according to some forum discussion. But I always receive failure when I call pfsockopen function.

Any one has idea how to solve this?

Thanks!