In theory you should be able to do it, how hard it is depends on if you can find a library to do it or how easy their interfaces are. I believe you should be able to communicate with anything on network through sockets, but especially if it's encrypted it can be a painful job.
As some suggest it might be easier to do with languages like Java, you can still make a cross to PHP for example communicate between PHP and Java through MySQL or directly with sockets, then you have the advantage of creating an easier socket interface in your Java application which becomes like a middle-driver.
Senior Data Engineer