bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

coding a php server with ncurses


From: Mike Robertson
Subject: coding a php server with ncurses
Date: Thu, 9 Jun 2005 08:33:46 -0400

I have been working on the following php server.  To give you some background.....I have a vb6 client that sends a string of 4 values that is on a timer to send values every second.  I need to have my server recieve these values every and disregard that previous value.  Basically I just need 4 values to be sent every second and continually updating.  I have ran into the problem in which I the code I have will recieve on value but not more than that.  It has been recommended that ncurses may be able to give me what I need to do this?  If true...here is my server code...I was wondering if you could explain a litttle bit to me about ncurse and offer me some insight on exactly what I may need to do tho get this thing running.  I am brand new to linux coding and php so I do not have much experience and knowledge at all.  Any information you could off would be appreciated.
 
<?php
> function giveMeAnArray($delimiter, $string)
> {
>    return explode($delimiter, $string);
> }
>
> $read_write = "read";
>
> if($read_write == "read")
> {
>   //Initialize the socket
>   set_time_limit(50000);
>   $address = "127.0.0.1";
>   $port = 10119;
>   $sock = socket_create(AF_INET, SOCK_STREAM,
> SOL_TCP);
>   socket_bind($sock, $address, $port) or die ('Could
> not bind to address');
>
>   //Start listening on the socket
>   //There could be a 'while true' or something here
> to make it infinite
>    //While(true)
>   // {
>       socket_listen($sock);
>
>       //Accept an incoming connection
>       $client = socket_accept($sock);
>
>       //Read whatever was just sent, 1024 bytes'
> worth.  Make this however
> long you need.
>       $global_string = socket_read($client, 1024);
>
>       print ("Serving Client!\n");
>
>       //Strip whitespace
>       $global_string = ereg_replace("[ \t\n\r]", "",
> $global_string).chr(0);
>
>       $delim = ',';
>
>       $array = giveMeAnArray($delim,
> $global_string);
>
>       //for($i=0; $i < count($array); $i++)
>       //{
>         print("Coil ID number: $array[0]\n");
>         print("Coil Width: $array[1]\n");
>         print("Footage Count: $array[2]\n");
>         print("Coil Length: $array[3]\n");
>       //}
>
>     //Close the while loop here, if you had one
>
>       //Close the connection; and the socket itself.
>       //socket_close($client);
>       //socket_close($sock);
>
>       //print ("Closed socket successfully\n");
>       //print ("Server exiting now...\n");
>
> }    //ends if ("read")
> ?>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]