https://www.reddit.com/r/PHP/comments/107ehex/comment/j3r2ksv/
Newing socket factory in the Connection constructor only to create a socket client and throw the socket factory away hints that there should be a ConnectionFactory instead. It should accept socket factory in constructor. And offer a createConnection method that would call createClient on the socket factory and pass the returned socket client instance to constructor of Connection and then return the connection instance.
The callback parameter of Connection constructor is also weird. Why don't you just call the callback code after obtaining the new Connection instance?