Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

http server in php

I want to create http socket connection for server in php for multiple client . how can I do that ? I need some resource .

First I was trying to create server in java .I create a server in java . And trying to reach from android application .But server can't find any client.But when I create client in java .It was working. How can I solve that problem ???

like image 986
Diptopol Dam Avatar asked May 09 '11 13:05

Diptopol Dam


3 Answers

Take a look at this article:

Writing Socket Servers in PHP by Zend

Also give a try with Google:

http://www.google.com/search?aq=0&oq=php+socket+server+mul&sourceid=chrome&ie=UTF-8&q=php+socket+server+multiple+clients

like image 82
Adnan Avatar answered Sep 26 '22 13:09

Adnan


Personally I think this would be a pretty bad idea, as already mentioned it lacks Threading and it's Socket support (imo) isn't really that adaptable.

The only plus side is that you can use fork to fork off another PHP process to handle a client, but you're getting very complex.

Another language would be much more suited for this type of development.

Note that even if you did do this in PHP, you'd probably have to rely on external services anyway, and possibly even end up writing at least some code in another language anyway.

like image 21
Rudi Visser Avatar answered Sep 25 '22 13:09

Rudi Visser


You're trying to use PHP to do what? Mind you, I like PHP and work with it almost every day, but please do remember PHP in and on itself is based on request and response, and not very suitable for long running processes. In a manner of exercise, it might be interesting, but if you're trying to write a webserver from scratch using PHP, you might want to reconsider your choice of language.

That said, you can create a socket acting as a server, and listen to incoming packets. I do still think you're reinventing the wheel though.

like image 45
Berry Langerak Avatar answered Sep 26 '22 13:09

Berry Langerak