Maybe this will help, maybe not, but I just got done creating an AIM/TOC bot and socket gateway. I ran into almost the same problem as you did. I wanted to be able to have web pages interact with the AIM network. But AIM has a log in/out rule set that says if you log in and out too often, it will lock that user out for 10 minutes since the last log in attempt.
I found some AIM/TOC protocol code for PHP and built around it. I'm not sure who originally wrote it. I was too excited to see if it would work then try rewriting it into a class or something. I built an AIM bot around it and then realized I could build in a socket server into the AIM bot. You can find the code here:
http://www.rsbauer.com/webdev.php
Its not MSN code, but I'd think if you can work out the MSN code, you could figure out how to integrate the socket server code.
I looked into how to save the socket while trying to reload a PHP script and didn't have any luck. I also tried figuring out how to dynamically reload PHP functions and I ran into some code that came close to working, but it didn't fit my needs.
So, I ended up writing a socket server to listen for connections (either via Telnet or some socket client such one from PHP). This is handy because now my pages can log into the socket server and pass any commands along and then log off, without effecting the AIM connection.
The socket server code is smart enough to keep track of the various socket connections and keeps them straight. But the AIM code is not. I believe the problem this will cause is if the socket server needs to listen to data coming back from the AIM session, it could get mixed with another on going AIM session. Not good. I think if the AIM code was in a class and then the individual sessions could be tracked a lot easier (probably with an array of AIM classes) but all the classes would only be using one AIM socket connection.
For what I'm looking to do, the code works, but I wouldn't mind rewriting it when I get more time. As for performance, the socket server puts a little bit of a burden on the AIM bot processing code and its not as snappy as I'd like it. But its running off of a Pentium 100Mhz box so that may be a factor too.
I don't use MSN so I'm not much help with that. But maybe my code will spark some ideas...