Jump to content

Search the Community

Showing results for tags 'sockets'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 6 results

  1. I am currently streaming my mp4 files perfectly fine using php. My issue is, how do I detect when the video is either no longer being watched, or disconnected? I need to run a function after this so that I know the video is no longer being watched for analytics. Is there a way maybe with sockets or something? I'm currently using this. if (file_exists($request)) { $fp = @fopen($request, 'rb'); $size = filesize($request); $length = $size; $start = 0; $end = $size - 1; header("Content-Type: video/mp4"); header('Accept-Ranges: 0-' . $length); if (isset($_SERVER['HTTP_RANGE'])) { $c_start = $start; $c_end = $end; list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); if (strpos($range, ',') !== false) { header('HTTP/1.1 416 Requested Range Not Satisfiable'); header('Content-Range: bytes ' . $start . '-' . $end . '/' . $size); exit(); } if ($range == '-') { $c_start = $size - substr($range, 1); } else { $range = explode('-', $range); $c_start = $range[0]; $c_end = (isset($range[1]) && is_numeric($range[1]) ? $range[1] : $size); } $c_end = ($end < $c_end ? $end : $c_end); if (($c_end < $c_start) || (($size - 1) < $c_start) || ($size <= $c_end)) { header('HTTP/1.1 416 Requested Range Not Satisfiable'); header('Content-Range: bytes ' . $start . '-' . $end . '/' . $size); exit(); } $start = $c_start; $end = $c_end; $length = ($end - $start) + 1; fseek($fp, $start); header('HTTP/1.1 206 Partial Content'); } header('Content-Range: bytes ' . $start . '-' . $end . '/' . $size); header('Content-Length: ' . $length); ob_end_flush(); $buffer = 8192; $time_start = time(); $bytes_read = 0; while (!feof($fp) && (($p = ftell($fp)) <= $end)) { $response = stream_get_line($fp, $buffer); echo $response; $bytes_read += strlen($response); if (30 <= time() - $time_start) { file_put_contents('/var/www/html/movieCon/'.$user.'_'.$token.'_'.$movie_id.'.con', time()); $time_start = time(); $bytes_read = 0; } } fclose($fp); exit(); }
  2. Welcome, I try to build interface to communicate with an application (remote console) using its own protocol and php sockets. Problem is that I have huge experience using most of php librariers and functions but no experience with using pack at all, not mention to create packets using it. Second problem is that application does not respond if packet does not have proper format. I tried to build something using that pack function and its documentation but packet is more complicated then I thought. Can some one show me how to build proper packet using format on page 2 of this document or at least explain how to do it properly?
  3. Hi everyone!! I am developing a concurrent websocket server in PHP. I prefer to implement it using pthreads rather than using fork to create new processes, because the server is supposed to handle thousands of connections, and threads are lighter than processes. But when I execute this code: <?php class My extends Thread { public function run() { /** ... **/ } } $my = new My(); var_dump($my->start()); ?> I get this error: PHP Fatal error: Class 'Thread' not found in /home/user/htdocs/example/server.php on line 3 Why?? How can I get pthreads working in PHP?? By the way, do you have another suggestions to implement the concurrent server?? I am using Ubuntu 12.04 64bits Thank you very much!
  4. Suppose i had a Registration Form with multiple fileds(like first name,last name etc).And i want to enter the entered values into MySql using Sockets... I need the example showing inserting data into Mysql using sockets.Bcoz i learned something about php sockets but i don't have the basic idea how to implement them...Even i tried so many examples but i tired of having so many complexities like socket_bind,socket_accept,socket_listen errors... THANKS IN ADVANCE...
  5. Hello, I am trying to send some hex bytes to a remote socket to switch off a display. I have a java applet which is able to switch off the display by opening a socket. I have tried creating a socket in php and writing the bytes but its doesn't work. I have captured with wireshark with each program does and the php program sends multiple frames where as the java one just sends one. I have attached both wireshark capture files (remove the .txt suffix) and my php code. I am using a wxbinder with my php code which explains some of the functions. The java applet & source code can be found here http://networktools.sourceforge.net/ Is there any way I can use php to send exactly the same frames / packets as the java applet? If you need any more info please ask Thanks, Dan from networktools.txt from php app.txt php-socket.txt
  6. Iam working on a multi-users online game and the scenario is :- 1- I fork a new process for each connection 2- first i stared with making a shared object with (unix sockets) , this object was containing the shared data among the process (ie: this object was the responsible for intercommunication between the processes 3-But i notice that there is al ot of errors on the data returned from the shared objects (unexpected data). 4- so i separated my code and start to depend only on memcache(with 1024 storage capacity) to transfer objects among the processes. 5- the users can play with each other in a specific room. 5-each user has on object(instance of player class) in the memcache 6-each room has an object(instance of room class) in the memcache The problem is : - all is ok if there is a few number of players in the server but If there is a lot of players in the server the memcache produce an error Memcache::get(): Server localhost (tcp 11211) failed with: Malformed VALUE header (0) Memcache::replace(): Server localhost (tcp 11211) failed with: Received malformed response (0) Memcache::get(): Server localhost (tcp 11211) failed with: Failed reading line from stream (0) and some times the memcache return to me an object of player instead of object of room ex: $memcache->get("player1") should return an object for a player class but it sometime return an object for a room class $memcache->get("room1") should return an object for a room class but it sometime return an object for a player class i did not know what is the problem
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.