Question

I'm working on an idea of mine which is comparable to a home automation system. The layout of network devices would be like this: enter image description here

What I want is for my Mobile Phone App to be able to communicate with the home server at all times, but also for the server to be able to reach my phone (Push-notifications). For this I thought it would be a good idea to implement TCP-Holepunching using my server in the datacenter as the center for traffic.

The problem is though, Since my Java skills aren't good enough yet, I'm forced to write my server in the PHP scripting language, but PHP isn't capable of keeping sockets active.

Is there TCP-holepunching server software (executable in Debian) available which would be able to keep the sockets alive and push any commands from my server towards the correct destination (ie: phone) and vice versa?

Était-ce utile?

La solution

There are ways to get sockets working in PHP. One library that does this can be found here: http://socketo.me/

Also an easy way of setting a server like this up can be done with NodeJS. You code your server in JavaScript (run on Google Chrome's V8 Engine) and then you can handle persistent connections based on events.

It should be possible (with NodeJS) to code a relay server (relaying from your phone to your home PC and vice versa) with only a few lines of code.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top