I'm working on a web application that will receive gps data and split received string to detailed information and then store it in some database tables.

Every piece of application is ready, now I need to setup my new server to accept data from gps device.

In my gps device, we have to set an IP and a port that will point to my host. -( my devices are using TCP )-
Server OS is linux CentOS 6.5 and there's a directadmin installed on it.

After a couple of days research, I figured it out that I have to open a port -(31334 in my cases, because the previuos app was working using this)-.
BUT
I can't find out how should I forward inbound data from this port to the file that will handle packets.
Let's say :
I wrote a php file named : gettcp.php
The device will send data using 1.2.3.4 : 31334 (my host ip and port)
How server should find out incoming packets from 31334 have to go to gettcp.php ...???
What's the scenario ...?
AND what should I configure in my host? Should I use directadmin or my linux shell?

If you run "php --help" you will see that one of the options is to run PHP directly as a web server (no LAMP stack required), which is the "-S <addr>:<port>" option. IE, you can do this directly in PHP by starting it with the correct address and port information. You should then get the data directly. Try this

php -S 1.2.3.4:31334 gettcp.php

directly from the command line. You can do it in the shell. I don't think you have to run it as admin. I used to do this to test my PHP code at Nokia. In some cases, we would just use it as-is and not bother with Apache or Ngnix.

You can also run it in the background, but that isn't necessary.

commented: Thanks, It would be great if you check my new answer +0

Thanks for your reply.

Is this possible that this command corrupt or misconfigure my current running php? Or it just change setting for this special port?

I'm asking because my site is running on the same server?

Well, I did test it and it seems OK temporarily, because when I hit Ctrl + c, the process will be gone.
May be I have to run this in the background, as you mentioned above.
I need this to be working permanently.
Either I have another problem that the command message says:

[Sat Dec  5 21:31:27 2015] 5.107.127.148:1334 Invalid request (Malformed HTTP request)

Can anyone help me to fix that?

Well, I would need to see the incoming http request to determine why it is "malformed". FWIW, once we were satisfied that the php code was working correctly, we could deploy it in a real web server (Apache) without problems, but you need to tell Apache that it needs to listen on the new port.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.