yes it can be done.
php has full socket support, and bitwise manipulations, so you just have to know how to connection over an arbitrary socket to a listening server, the what to say to it.
the last part is the thing i don't know about.
search through the archives for 'sockets' here there have been some good stuff on this board about how to use them