473,394 Members | 1,956 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,394 software developers and data experts.

Problem with permanent socket connection

Hi,

I want to open a permanent socket connection to a service witch is running
on the same computer.
After I logged in on my php page, I start a session. After this a socket
connection should be opened to a service
I get data from. Now my problem is I want open only once a socket connection
to the service and after this I want use on
all php pages this connection. How can I transmit (or use) this one
connection on all pages ?

I opened the socket connection like this:

$fp = pfsockopen ($url, 1006, $errno, $errstr, 10);

This code snippet is running correctly, but on the next php page I can't use
this connection.

Thanx for Help

May 2 '06 #1
1 2706
On Tue, 02 May 2006 13:38:59 +0200, Ismail Demiralp wrote:
After I logged in on my php page, I start a session. After this a socket
connection should be opened to a service I get data from. Now my problem
is I want open only once a socket connection to the service and after this
I want use on all php pages this connection. How can I transmit (or use)
this one connection on all pages ?
Write a daemon that opens this socket, then pass commands to the daemon
(maybe by signals, maybe using a socket) from PHP.
I opened the socket connection like this:

$fp = pfsockopen ($url, 1006, $errno, $errstr, 10);

This code snippet is running correctly, but on the next php page I can't
use this connection.


Have you read the comments on php.net:

http://uk2.php.net/pfsockopen

OK, WRT to the p* functions opening a new connection when one already
exists. It is my understanting that (under Apache anyways) this is on a
per-process basis. If you do a 'ps auxw|grep httpd' on your server you
will see more than one process. What p* does is make a p-connection on one
of those processes only, the one that actually handles your request.
Chances are that when you hit the page again it will be answered by a
different process. I'm guessing if you keep hitting reload you'll get
around to the original process again and there will be no error message or
second connection open. Anyhow, this is true of all p* functions; they
open not one connection per server, but one connection per server _process_.
Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

May 2 '06 #2

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

Similar topics

3
by: Thomas Hervé | last post by:
My problem is not really python specific but as I do my implementation in python I hope someone here can help me. I have two programs that talk through a socket. Here is the code : <server>...
4
by: flupke | last post by:
Hi, I have a gui (made in wxPython) that enables a user to connect to a server and issue some commands. The problem occurs when i try to disconnect the client. It exits but it doesn't return to...
2
by: Droopy | last post by:
Hi, I try to implement a reusable socket class to send and receive data. It seems to work but I have 2 problems : 1) I rely on Socket.Available to detect that the connection is closed (no...
1
by: piotrek | last post by:
Hello all. I have a problem and my solution but i have to make sure that it want cause memory problems. i have a class FTP and 'private Socket CONNECTION = null;' Then i have a method PASV()...
1
by: Mr. Beck | last post by:
Hello, Please Help..... I have been working with some tcp/ip socket communication within a C# program recently. Basicly, I have a program (myProblemProgram) that has a socket connected to...
10
by: Clayton | last post by:
Hi all, I'm trying to develop a server that listens to incoming calls using the asycnhronous methods BeginAccept / EndAccept. I start the server (till this point it is ok) and few seconds later...
8
by: Chizl | last post by:
I'm building a web server and having some issues with the TCPListener.Start(BackLog). It doesn't seem to do as expected. I'm using MS Web Stress Tool to test against my web server and when I...
2
by: Jean-Paul Calderone | last post by:
On Mon, 12 May 2008 11:16:08 -0700 (PDT), petr.poupa@gmail.com wrote: I'm not sure if you need to write a server or a client. In your original code, you had a client which repeatedly established...
1
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.