php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43026 persistent sockets do not stay persistent
Submitted: 2007-10-18 23:20 UTC Modified: 2007-10-19 08:28 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: domino at operamail dot com Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.2.4 OS: Linux / Fedora 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
44 + 12 = ?
Subscribe to this entry?

 
 [2007-10-18 23:20 UTC] domino at operamail dot com
Description:
------------
Socket handle as returned by pfsockopen is not preserved within the same session.

First page will open a persistent socket and store it in the SESSION array. (Yes, i have a component running on 20505).

Then, first page redirect to second page, which retrieves the stored object.

The string is retrieved OK from resumed SESSION, but socket is dead.

PS. As a test, I have reconfigured Apache to run in single thread mode. The code sample still doesnt work as expected.

Reproduce code:
---------------
socket.php:

Code:

<?php
session_start();


$_SESSION['langleySockets'] = array();
$_SESSION['langleySockets'][0] = array( 'hi' => 'bye', 'socket' => fsockopen("127.0.0.1", 20505));

$fh=fopen("/tmp/socket.xxx", "w");fwrite($fh, print_r($_SESSION['langleySockets'][0], true));fclose($fh);

session_write_close();

header("Location: socket2.php" . "?" . SID);

?>



socket2.php:
Code:

<?php

session_start();
$fh=fopen("/tmp/socket.xxx", "a");fwrite($fh, print_r($_SESSION['langleySockets'][0], true));fclose($fh);
session_write_close();

?>


Expected result:
----------------
[root@xyz db]# cat /tmp/socket.xxx
Array
(
    [hi] => bye
    [socket] => Resource id #15
)
Array
(
    [hi] => bye
    [socket] => Resource id #15
)

Actual result:
--------------
[root@xyz db]# cat /tmp/socket.xxx
Array
(
    [hi] => bye
    [socket] => Resource id #15
)
Array
(
    [hi] => bye
    [socket] => 0
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-19 08:28 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Resources can't be stored in a session, not even persistent ones. Instead the persistent connection will be reused when you reopen a connection with the same parameters. Please also see http://php.net/manual/en/features.persistent-connections.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 15:01:29 2024 UTC