Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to listen UDP and make use of PHP

I have to build up a system which listens for requests from a GPS device which is only capable of sending UDP requests. Then I am going to analyze requests hopefully by PHP if it is possible.

I do not know where to start. What do I need? Can I make use of PHP? Would it be reliable to use PHP? Can I just adjust Apache for listening UDP requests?

like image 961
pars Avatar asked Jan 23 '23 06:01

pars


2 Answers

I do not know where to start.

You need a notion of an overall program design, and, as @karim79 pointed out, an understanding of socket programming APIs for your chosen language.

Can I just adjust Apache for listening UDP requests?

Do you mean the Apache httpd? The short answer is "no."

Use something like PEAR's System_Daemon instead.

The long answer is "yes, that is possible." Particularly with modular plugins exposing the httpd's internals, you can do Just About Anything You Want (tm) (see, for instance, mod_perl). You could beat httpd into a sort of application server for a long-running (set of?) PHP process(es) which are not themselves intrinsically HTTP-driven.

The better answer of the two is, again, "no." :)

like image 144
pilcrow Avatar answered Jan 25 '23 21:01

pilcrow


By all accounts I think PHP should be fine for that, but I haven't done anything like that myself. You will need to look into socket programming, here's a tutorial:

http://www.devshed.com/c/a/PHP/Socket-Programming-With-PHP/

like image 31
karim79 Avatar answered Jan 25 '23 20:01

karim79