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!
Dear all,
I have been using php script for developing my web server. Basically this server listens for client socket and accept incoming messages and return back to the client. The below is the code . The problem is , when the script executes socket_accept() it blocks the code and hence I am unable to print the echo values before that. The page remains blank. How do i overcome it.. I want the values to be printed in the page and later on the socket_accept can go for blocking how do i do that. what is the problem in this code pls reply
Now i dont find any issues executing the first 3 scripts but when the execution reaches script 4 it hangs... what are the reasons due to which the socket_server can hang? BTW i was able to run the same script few days back but the same is not running now. Is there anything that i need to enable in my server or how do i debug it? There are no compile errors also when i try to run the client to connect the server using telnet i get
Connecting To xx.xx.xx.xx...Could not open connection to the host, on port xxxx: Connect failed.
How do i go about and please find my initial post for the code.
the socket_accept() isn't hanging, it's blocking ie waiting for an incoming connection. In order to override this behavior you should use the function from my previous post.
About you connecting with telnet, what command are you using??
Dear all,
This is yet another parallel post from me regd php sockets . This is my requirement
1. I need to write a web server application using PHP and this could be on one of the free web hostings servers that provide php functionalities.
2. I have written the PHP server code on the free web server but the problem is the port, as I dont get a dedicated port for server to listen. So i used a polling method to get the open port and display it on the webpage so that client can use it to make connection.
3. After knowing in which port the server is listening i can use telent to connect to the web server with the port. u:\> telnet host port
The problem
1. In order to display the available port on the webserver i used "print $port;" and after that socket_accept() is called. Since the socket_accept() is a blocking call the "print $port" is not displayed on the screen. Due to which i could not know on which port the server is listening and the client could not make a connection to the server.
What are the ways available for the client to know on which port the server is listening keeping in mind the server takes a random free port and there is no dedicated port available?
And since this is free web hosting server there might be several other programs running in the same host listening to different ports.
I believe I am doing something wrong fundamentally which i am not getting to know because the code which i am using has no errors and well tested.