473,327 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

socket and session

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?

Sep 26 '05 #1
1 3450
fu***@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
Sep 26 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Colin Brown | last post by:
Python2.3.2: Running the following receiver and sender code in separate windows under Win2K does not work properly (missed & very delayed transmissions). Under Redhat Linux 9 (where I will be using...
1
by: Mike | last post by:
Hey! Im using a derived HTTP socket server, the base class in python. I've got a modified version of the implementation, right now I want to introduce authentication of users in my server. What...
2
by: Joe Wong | last post by:
Hello, I have a short program that the client make a connection to server, a thread is then created to poll any data sent from the server. The main thread will close the socket after 5 seconds....
2
by: Nick Zdunic | last post by:
Ok - something for socket jockeys I have a .NET application using the TcpClient class from System.Net.Sockets I use this to connect to an IP address/Socket on the other side of Australia. ...
1
by: JDF | last post by:
I am fairly new to python and seem to have gotten ahead of myself. I am trying to write a Windows service that will return the current number of Citrix sessions to a client. This service will run...
3
by: Paul W | last post by:
I have a socket-based app running that spawns a different socket for each user and I was looking for a way to optimize it a little better. Currently I keep a collection of active sockets (300 -...
6
by: Sharon | last post by:
Hi all. I'm trying first time async socket connection. In all the examples i've seen, the server connection is closed when the message is complete. Is it common to close the connection after...
5
by: Steven Blair | last post by:
I need to write an ASP.NET application which can do the following: 1. Create a socket which will stay alive and continously read data. 2. The data read needs to be displayed on the webpage. 3....
1
by: hankypan1 | last post by:
Hi All, I am developing a multi threaded CLI application which will be running over the socket interface. So i need to have a telnet server sort of thing, command line editor application with...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.