Reply to Re: socket and session

Your name:

Reply:


Posted by Erwin Moller on 09/26/05 15:37

fufik@op.pl wrote:

> Hi,
>
> I'm trying to connect to an application server using sockets.
> Everything is fine with a small exception. I would like to store socket
> in session, so that I wouldn't have to reconnect at every request.
>
> I open socket using (PHP5): stream_socket_client.
> Then I try to: $_SESSION["socket"] = $newSocket.
>
> With every new request the $_SESSION["socket"] is 0.
>
> Anyone got any idea how to solve it?

Don't.
All handles are destroyed at the end of the request, and the only thing you
can store in a session is a stale handle (to a socket or filehandle, or
databaseconnection).
So that makes no sense, because when you unserialize that handle (by using
it in your session on a new page) it is broken.

So you are stuck with reconnecting every request. :-(
(AFAIK: Only connections to the database can be made more permanent, but not
by using a session, but by using another way to connect to the database.)

regards,
Erwin Moller

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация