Receive TCP data packets in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ulala099
Forum Newbie
Posts: 9
Joined: Sat Jun 14, 2008 11:19 am

Receive TCP data packets in php

Post by ulala099 »

Hi,
I am new in this forum and php as well. I am familiar with (php?getdata=data) type format, but don't know how it connects in TCP/IP layer to receive tcp packets.

My embedded device sends data (in fixe format) using TCP protocol. I can only set server IP address, port number and TCP or UDP. I want to receive that data in my web server and store in mysql database.

Now my questions are -
1. Is it possible to receive data using php? if it is then how can I receive that data using php?
2. Do I need static IP to receive data? Or I can do it using shared hosting? How?
3. Is it possible to receive tcp data packet using port 80? how?


Please advise me what to do to receive TCP data packets using php. If possible then please refer some examples of similar types of data send/receive php codes.


Thanks in advance.
darklord18
Forum Newbie
Posts: 8
Joined: Sun Jun 08, 2008 7:57 pm

Re: Receive TCP data packets in php

Post by darklord18 »

Hello! I not a great expert, but you can do that with the socket. You will have to open up a socket to listen to any request.


you can check this out:

http://www.devshed.com/c/a/PHP/Socket-P ... ith-PHP/1/

It may help you!

The problem that i am facing is how to make it always run without opening a page.
I think this should be done by using the CLI, but how??
And what is the PHP binary???
ulala099
Forum Newbie
Posts: 9
Joined: Sat Jun 14, 2008 11:19 am

Re: Receive TCP data packets in php

Post by ulala099 »

Hi,
Thanks for the link. I was wondering when there are several hundred of users will connect by TCP and send data in every minute continuously then how can I manage that? Should I keep the listening socket open forever? Or everytime close and open? How will it handle hundreds of data continuously?

Please advise me how to solve the problem.

Thank you.
Post Reply