473,569 Members | 2,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About Resource id's

Hello,

I am using a simple php server that I wrote and have some questions
related to the resource id's. When a new client connects to the server
or the server opens a file the Resource id number increases normally,
but when the server closes the socket and the file and then a new
client connects or file opens, the Resource id still increases without
reseting to the previous closed id's.

For example:

Client connects to the server...accept ();
Client fd: Resource id #1
client quits.... fclose/socket_close
Client connects to the server...accept ();
Client fd: Resource id #2
client quits.... fclose/socket_close
....
....
....
Client connects to the server...accept ();
Client fd: Resource id #12456

Shouldn't the resource id reset to #1 when the second client
connected ? Can this behaviour cause problems to the server ?

I wrote a simple socket server and client to demonstrate this:

server:
----------

<?php
set_time_limit( 0);

$socket = stream_socket_s erver("tcp://0.0.0.0:6000", $errno, $errstr);
if (!$socket) {
echo "$errstr ($errno)<br />\n";
} else {
while ($conn = stream_socket_a ccept($socket)) {
testme();
testme();
testme();
print("Client fd: ".$conn." \n");
fclose($conn);
echo '$socket is resource = ' . (is_resource($c onn) ? 'true':
'false')."\n";
}
fclose($socket) ;
}

function testme() {
$fp = fopen('testfdss ','a');

fclose($fp);
echo '$file_pointer is resource = ' . (is_resource($p ) ? 'true':
'false')."\n";
}
?>

client:
---------

<?php
set_time_limit( 0);

while(true) {
$fp = fsockopen('127. 0.0.1',6000,$er rno,$errstr,(fl oat) 1);

if (!$fp) {
print("error()\ n");
}

fclose($fp);
}
?>

Thanks for your help and sorry for my (bad) english

Oct 27 '07 #1
21 6744
DiAvOl wrote:
Hello,

I am using a simple php server that I wrote and have some questions
related to the resource id's. When a new client connects to the server
or the server opens a file the Resource id number increases normally,
but when the server closes the socket and the file and then a new
client connects or file opens, the Resource id still increases without
reseting to the previous closed id's.

For example:

Client connects to the server...accept ();
Client fd: Resource id #1
client quits.... fclose/socket_close
Client connects to the server...accept ();
Client fd: Resource id #2
client quits.... fclose/socket_close
...
...
...
Client connects to the server...accept ();
Client fd: Resource id #12456

Shouldn't the resource id reset to #1 when the second client
connected ? Can this behaviour cause problems to the server ?
Why should it? The actual value is immaterial. It is only a unique id
used to identify a reference.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Oct 27 '07 #2
Why should it? The actual value is immaterial. It is only a unique id
used to identify a reference.
What if the above code example runs forever ? The resource id will be
increasing forever and overflow sometime...


Oct 27 '07 #3
..oO(DiAvOl)
>Why should it? The actual value is immaterial. It is only a unique id
used to identify a reference.

What if the above code example runs forever ? The resource id will be
increasing forever and overflow sometime...
It's handled internally by the interpreter. Don't worry about it.
The engine is smart enough to keep an eye on such things.

Micha
Oct 27 '07 #4
DiAvOl wrote:
>Why should it? The actual value is immaterial. It is only a unique id
used to identify a reference.

What if the above code example runs forever ? The resource id will be
increasing forever and overflow sometime...


Then you'll need an infinite number.

But nothing runs forever.

What is your real PROBLEM? Or are you just looking for one?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Oct 27 '07 #5
On Oct 27, 9:22 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
DiAvOl wrote:
Why should it? The actual value is immaterial. It is only a unique id
used to identify a reference.
What if the above code example runs forever ? The resource id will be
increasing forever and overflow sometime...

Then you'll need an infinite number.

But nothing runs forever.

What is your real PROBLEM? Or are you just looking for one?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===
I am running a stream_select server which actually runs forever
(daemon mode) and I worried because the Resource id number is around
29000 so far and I don't know what happens if that number increases
forever. Another reason for asking is because maybe someone have read
the source code and knows better about it.

Thanks

Oct 27 '07 #6
DiAvOl wrote:
On Oct 27, 9:22 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>DiAvOl wrote:
>>>Why should it? The actual value is immaterial. It is only a unique id
used to identify a reference.
What if the above code example runs forever ? The resource id will be
increasing forever and overflow sometime...
Then you'll need an infinite number.

But nothing runs forever.

What is your real PROBLEM? Or are you just looking for one?

--
============== ====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attg lobal.net
============== ====

I am running a stream_select server which actually runs forever
(daemon mode) and I worried because the Resource id number is around
29000 so far and I don't know what happens if that number increases
forever. Another reason for asking is because maybe someone have read
the source code and knows better about it.

Thanks

So? Do you think it's going to run for years without a server reboot?
NOTHING runs forever!

How long has it been running to get to 29K?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Oct 27 '07 #7
..oO(Jerry Stuckle)
>DiAvOl wrote:
>I am running a stream_select server which actually runs forever
(daemon mode) and I worried because the Resource id number is around
29000 so far and I don't know what happens if that number increases
forever. Another reason for asking is because maybe someone have read
the source code and knows better about it.

So? Do you think it's going to run for years without a server reboot?
Possible.
>NOTHING runs forever!
Just think of older Windows versions - without reboot they crashed after
49 days because of an internal integer overflow. But I really think that
the PHP interpreter is capable of handling such things and clever enough
to re-use free resource IDs if necessary.
>How long has it been running to get to 29K?
I was about to ask a similar question. And even if PHP would just
increase the number - what about the "natural" limits? A 32bit signed
integer is more than 2*10^9, unsigned it's twice as big (I simply assume
PHP doesn't use just 16bit words ...)

Micha
Oct 27 '07 #8
Michael Fesser wrote:
.oO(Jerry Stuckle)
>DiAvOl wrote:
>>I am running a stream_select server which actually runs forever
(daemon mode) and I worried because the Resource id number is around
29000 so far and I don't know what happens if that number increases
forever. Another reason for asking is because maybe someone have read
the source code and knows better about it.
So? Do you think it's going to run for years without a server reboot?

Possible.
No, Micha, it isn't in the real world. But maybe it is in your fantasy
land.

Or are you just trolling again? I suspect that's the case.
>NOTHING runs forever!

Just think of older Windows versions - without reboot they crashed after
49 days because of an internal integer overflow. But I really think that
the PHP interpreter is capable of handling such things and clever enough
to re-use free resource IDs if necessary.
So what if Windows crashed after 49 days? And do you KNOW the PHP
interpreter can handle it? Can you point to the code? Or are you just
guessing - as usual?
>How long has it been running to get to 29K?

I was about to ask a similar question. And even if PHP would just
increase the number - what about the "natural" limits? A 32bit signed
integer is more than 2*10^9, unsigned it's twice as big (I simply assume
PHP doesn't use just 16bit words ...)

Micha
It was a rhetorical question, Micha. And instead of guessing, why don't
you find out? It's not that hard to prove.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Oct 27 '07 #9
..oO(Jerry Stuckle)
>Michael Fesser wrote:
>.oO(Jerry Stuckle)
>>DiAvOl wrote:

I am running a stream_select server which actually runs forever
(daemon mode) and I worried because the Resource id number is around
29000 so far and I don't know what happens if that number increases
forever. Another reason for asking is because maybe someone have read
the source code and knows better about it.
So? Do you think it's going to run for years without a server reboot?

Possible.

No, Micha, it isn't in the real world. But maybe it is in your fantasy
land.
Servers _can_ run for years unless there's a hardware failure or a
kernel update.
>Or are you just trolling again?
I never did.
>I suspect that's the case.
Sure you do. I would be really surprised if it would be any different.
BTW: You still didn't answer my latest questions from the other threads.
>Just think of older Windows versions - without reboot they crashed after
49 days because of an internal integer overflow. But I really think that
the PHP interpreter is capable of handling such things and clever enough
to re-use free resource IDs if necessary.

So what if Windows crashed after 49 days? And do you KNOW the PHP
interpreter can handle it? Can you point to the code? Or are you just
guessing - as usual?
I was just posting my opinion and you're offending me again without any
reason. Forgot your pills again?
>>How long has it been running to get to 29K?

I was about to ask a similar question. And even if PHP would just
increase the number - what about the "natural" limits? A 32bit signed
integer is more than 2*10^9, unsigned it's twice as big (I simply assume
PHP doesn't use just 16bit words ...)

It was a rhetorical question, Micha. And instead of guessing, why don't
you find out? It's not that hard to prove.
Why should I? I'm not the OP, I don't have that "problem". I just
pointed out that it might not be a problem at all.

But I don't expect that you understand that. Just keep on going
insulting me, if you have nothing better to do.

Micha
Oct 27 '07 #10

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

Similar topics

3
59572
by: Ross | last post by:
Building a simple PHP/MySQL database interface. All SELECT queries return: "Resource id #2" What is this Resource id? Is there a list of them described somewhere? Looked all over php.net Many thanks! -Ross
3
4260
by: Danny Pressley | last post by:
Hey All, After a doc/view/frame is created and initialized, is there a way from within the frame class code (CMyChildFrame::OnUpdateFrameMenu()) to get the resource ID (nIDResource = IDR_???TYPE) used by CFrameWnd::LoadFrame()? I know the member variable m_nIDHelp is set to nIDResource in the LoadFrame() call, but don't feel that is a...
1
1715
by: charles hamm | last post by:
I am developing an app that has lots of similar dialog boxes. I have successfully cloned them using the text editor in the resource script file, and by entering the ID's in resource.h using the text editor. Everything seems to work. But now I look back in resource.h and find that some ID's have identical ID numbers. I think I realize how this...
9
2822
by: Alf P. Steinbach | last post by:
<what to design a C++ solution for> A Windows API /resource/ is data embedded in the executable, accessed via API functions. A resource is completely identified by the quadruple (id, type, language, file), where (1) id is what, for want of a better name, I'll call a /kludgeon/, (2) type is also a kludgeon, (3) language is a small integer...
1
2103
by: Chukkalove | last post by:
I originally created several "copy" resource reader classes which worked great individually, but after I converted them into an parent class with children they no longer find the resources. Each project contains its own reader class and resource .resx file from where a string or image is read. Can someone tell me what I need to do to get...
9
7410
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " . mysql_error()); mysql_select_db("my_dbf") or die("Grr");
6
3364
by: Stephen Torri | last post by:
I am trying to produce a singleton class that I can use throughout my library to write tracing information to a file. My intent was to design such that someone using the library in its debug mode would be able to see what was happening without having to use a debugger to step through each instruction. What they would do is run their program...
6
7168
by: Kye | last post by:
Can anybody please suggest to me where I can look up what a Resource id #71 is??? No success so far looking for what the resource codes are on the net. -- Yours Sincerely Kye
0
1976
by: =?Utf-8?B?UGF1bCBIYWdlcg==?= | last post by:
I've been trying to solve this issue for the better part of a month. My attempts to get an answer on the MSDN groups proved to no avail. Here is the situation/problem. I am migrating an old piece of software developed using VC++ 4.2, running on Windows NT 3.51 to VC++ 2005, running on Windows XP Pro SP2. I went through all of the...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7682
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2119
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1230
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
954
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.