well, from the errors that you described, $peer_host is blank.
so I could see what happens when it dies.
unfortunately, it just returned "unknown error", so that's not much help.
I think this may be due to a win32 problem, or something similar. Have you considered checking out