STREAM_SET_TIMEOUT(3) 1 STREAM_SET_TIMEOUT(3)stream_set_timeout - Set timeout period on a streamSYNOPSIS
bool stream_set_timeout (resource $stream, int $seconds, [int $microseconds])
DESCRIPTION
Sets the timeout value on $stream, expressed in the sum of $seconds and $microseconds.
When the stream times out, the 'timed_out' key of the array returned by stream_get_meta_data(3) is set to TRUE, although no error/warning
is generated.
PARAMETERS
o $stream
- The target stream.
o $seconds
- The seconds part of the timeout to be set.
o $microseconds
- The microseconds part of the timeout to be set.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 4.3.0 | |
| | |
| | As of PHP 4.3, this function can (potentially) |
| | work on any kind of stream. In PHP 4.3, socket |
| | based streams are still the only kind supported |
| | in the PHP core, although streams from other |
| | extensions may support this function. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
stream_set_timeout(3) example
<?php
$fp = fsockopen("www.example.com", 80);
if (!$fp) {
echo "Unable to open
";
} else {
fwrite($fp, "GET / HTTP/1.0
");
stream_set_timeout($fp, 2);
$res = fread($fp, 2000);
$info = stream_get_meta_data($fp);
fclose($fp);
if ($info['timed_out']) {
echo 'Connection timed out!';
} else {
echo $res;
}
}
?>
NOTES
Note
This function doesn't work with advanced operations like stream_socket_recvfrom(3), use stream_select(3) with timeout parameter
instead.
This function was previously called as set_socket_timeout(3) and later socket_set_timeout(3) but this usage is deprecated.
SEE ALSO fsockopen(3), fopen(3).
PHP Documentation Group STREAM_SET_TIMEOUT(3)
Hi, there
On HP-UX IA server, when calling 'accept' function in my program, the server never wait the client's connection. Each time, it accepted the request from IP address 0.0.0.0 even there is no client's connection. The server program looks like :
main()
{
.
.
.... (4 Replies)
how is an AVL tree implemented and insertions are made to itwenever a new socket is created and deletions are made when the socket is closed or connection is disconnected.how to read and print the names of all the current sockets. Please send the source code. (1 Reply)
Hello Everyone
Iam working on tcp/ip programming.with some time interval server has to send data.client has to close the connection and to open the connection between the time interval.this is the scenario
when iam closing the connection in client side the connection terminates.how to... (1 Reply)
i m using sockets for setting up a connection between a server and a client.
When the clients gets connected to the server, its ip is conveyed to the server through one of the predefined structures in c library...
i save this ip address in an array....1st client's ip address goes to the zeroth... (1 Reply)
Hi,
i'm using a TCP_IP socket.
everyone knows that in a client/server program, wen client sends a lot of packets continuously and if there is a delay in reading from the socket on the server side, the recv(), call reads everything from the buffer...
thats is the problem i'm facing. so i'm... (0 Replies)
Dear All,
I've searched many topics and googled many web-pages, but still I didn't found solution to this problem.
I want to set timeout for connect(). The thing is, that my code works only on BSD, on Linux (tested on SuSE box) it freezes at connect() call :(
bool
SomeFunc(std::string... (1 Reply)
hi all,
I've written a Server socket program in C++, In my program Device Id is a unique one through which I accept the client connection. My code has to pass the below two test case.
1. If a client the the same device is connceted already, i've to reject the new conncetion.
2. If i... (2 Replies)
hi,
i am new to socket programming.i have a problem in server.requirement is it should continuosly read the requests from client(sends requests continuously) and after certain delay(i kept der sleep) should send response.
for this i used msgqueues so that after reading it is sending into... (1 Reply)
I'm writing a small socket program (UDP) to communicate between two servers.
Problem is, I dont know how to implement time out hence my script keeps on waiting for the peer response.
#!/usr/bin/bash
use IO::Socket::INET;
$|=1;
$socket=new IO::Socket::INET->new(LocalPort=>5001,
... (2 Replies)
i am facing an issue that the server give a connection timeout after 60 sec for any request more than that number . i tried to increase the TCP INTERVAL TIMEOUT from the default 60000 ms to more higher number.
the server seems to work fine and didn't give me the massage of the timeout but the... (0 Replies)
Hi,
When can the read() system call gives timeout error when the same connection worked for writing data to the other end of the socket, while the next call with read() gives timeout error?
Can anyone please explain when this kind of situation appears?
Thanks,
Sanzee (2 Replies)
Hello,
I have a question about socket programming
The question was a homework of this university of past (2011?) course.
The server is simulating a sensor that provides readings of temperature, light and humidity (temp.dat, light.dat, humid.dat) each with single column of number, one per row. ... (6 Replies)