doujia1679 2013-05-12 17:00
浏览 102
已采纳

TCP Holepunch实现

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?

  • 写回答

1条回答 默认 最新

  • duangang2825 2013-05-18 21:32
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块