Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access raw Apache webserver request

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.

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

Thanks

like image 290
Ishan Karve Avatar asked Jun 04 '26 06:06

Ishan Karve


1 Answers

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.

like image 80
Marc B Avatar answered Jun 06 '26 19:06

Marc B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!