简体   繁体   English

访问原始Apache Web服务器请求

[英]Access raw Apache webserver request

I intend to design a web gps tracking application. 我打算设计一个web gps跟踪应用程序。 the gps transmits data using TCP (no HTTP headers) on port 7070 (which I intented to change to 80). gps在端口7070上使用TCP(无HTTP头)传输数据(我打算将其更改为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. 我知道GPS跟踪器和客户端之间的通信协议,但我卡住了,因为我无法拦截网络服务器上的数据包。 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. 由于应用程序处于开发阶段并且我是一个业余爱好者,我无法负担专用的Web主机服务器,因此可以访问用于套接字编程的php-cli接口。

is there any way i can circumvent the need for php-cli and intercept the raw tcp packet. 有什么方法可以规避php-cli的需要并拦截原始的tcp数据包。

Thanks 谢谢

Simply have a dedicated PHP script listening on port 7070, which you can accomplish with fsockopen() . 只需要一个专用的PHP脚本监听端口7070,您可以使用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. 当Apache已经在端口80上监听时,您不希望将GPS直接发送到端口80.Apache将看到非HTTP数据集进入并完全忽略该请求。

$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. 将是最简单的基本形式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM