What you're describing is not a job for PHP.
The PHP you use on your webserver is not stable if it runs for a long time. It is not meant to do that. If you want to create a cross-platform desktop application with PHP, you should check out PHP-GTK.
If you want to run chat off of your server, you should check out OpenFire, which is XMPP and does all the tough programming for you!
OpenFire is a chat server, which you install on your webserver, and you can use any XMPP-compatible program for your client, such as (my favorite) Pidgin, which is cross-platform and works for just about every kind of instant messaging or chat you can think of.
To do what you were proposing (kind of, not using sockets or listening or anything), have a look at the following links: