LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   source code for a php3 server (https://www.linuxquestions.org/questions/programming-9/source-code-for-a-php3-server-336474/)

mrobertson 06-23-2005 01:03 PM

source code for a php3 server
 
Does anyone have any source code avaiable for a php3 server that would be comprable to this socket coding done in php5?


Code:



if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {
                echo "socket_create() failed. Reason: " . socket_strerror($sock) . "<BR>";
        }

        if (($ret = socket_bind($sock, $address, $port)) < 0) {
                echo "socket_bind() failed. Reason: " . socket_strerror($ret) . "<BR>";
        }

        //Start listening on the socket
        if (($ret = socket_listen($sock, 5)) < 0) {
                echo "socket_listen() failed. Reason: " . socket_strerror($ret) . "<BR>";
        }

        //Accept an incoming connection
        if(($client = socket_accept($sock)) < 0) {
                echo "socket_accept() failed. Reason: " . socket_strerror($ret) . "<BR>";
                break;
        }

        //Read whatever was just sent, 1024 bytes' worth. Make this however long you need.
        if( false == ($global_string = socket_read($client, 2048))) {
                echo "socket_read() failed. Reason: " . socket_strerror($ret) . "<BR>";
                break;
        }


crabboy 06-24-2005 09:49 AM

Please do not post the same question in the forums more than once.

http://www.linuxquestions.org/questi...hreadid=336405

Closing thread.


All times are GMT -5. The time now is 02:10 AM.