访问原始的Apache网络服务器的请求 [英] Access raw Apache webserver request

查看:101
本文介绍了访问原始的Apache网络服务器的请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算设计一个网络的GPS跟踪应用程序。 GPS的传输使用TCP端口7070(无HTTP头)(我intented更改为80)的数据。我知道了GPS跟踪器和客户端之间的通信协议,但我坚持,因为我无法截取网络服务器上的datapacket。
由于应用处于开发阶段,我作为一个业余爱好者,我买不起一个专门的网络主服务器,从而获得访问PHP-CLI界面socket编程。

I intend to design a web gps tracking application. the gps transmits data using TCP (no HTTP headers) on port 7070 (which I intented to change to 80). I know the protocol for communication between the GPS tracker and client, however i am stuck as i cannot intercept the datapacket on webserver. Since application is in development stage and me being a hobbyist, I cannot afford a dedicated web host server and thus get access to php-cli interface for socket programming.

有没有什么办法可以规避为PHP-CLI的需要,并截取原始的TCP数据包。

is there any way i can circumvent the need for php-cli and intercept the raw tcp packet.

感谢

推荐答案

只要有一个专门的PHP脚本监听端口7070,您可以用的fsockopen完成()。你不想让你的GPS直接发送到端口80时,Apache的已在侦听端口80 Apache'll看到一个非HTTP设置数据进来,完全忽视要求。

Simply have a dedicated PHP script listening on port 7070, which you can accomplish with fsockopen(). You don't want to have your GPS sending directly to port 80 when Apache's already listening on port 80. Apache'll see a non-HTTP set of data come in and ignore the request completely.

$handle = fsockopen('localhost', 7070, $errno, $errstr);
if (!$handle) {
   die("Couldn't bind to socket (err $errno): $errstr");
}

while($data = fgets($handle)) {
    ... process gps data ...
}

将是这个最简单的基本形式。

would be the very simplest basic form of this.

这篇关于访问原始的Apache网络服务器的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆