Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

stream_socket_accept(3) [php man page]

STREAM_SOCKET_ACCEPT(3) 						 1						   STREAM_SOCKET_ACCEPT(3)

stream_socket_accept - Accept a connection on a socket created bystream_socket_server(3)

SYNOPSIS
resource stream_socket_accept (resource $server_socket, [float $timeout = ini_get("default_socket_timeout")], [string &$peername]) DESCRIPTION
Accept a connection on a socket previously created by stream_socket_server(3). PARAMETERS
o $server_socket - The server socket to accept a connection from. o $timeout - Override the default socket accept timeout. Time should be given in seconds. o $peername - Will be set to the name (address) of the client which connected, if included and available from the selected transport. Note Can also be determined later using stream_socket_get_name(3). RETURN VALUES
Returns a stream to the accepted socket connection or FALSE on failure. NOTES
Warning This function should not be used with UDP server sockets. Instead, use stream_socket_recvfrom(3) and stream_socket_sendto(3). SEE ALSO
stream_socket_server(3), stream_socket_get_name(3), stream_set_blocking(3), stream_set_timeout(3), fgets(3), fgetss(3), fwrite(3), fclose(3), feof(3), "cURL Functions". PHP Documentation Group STREAM_SOCKET_ACCEPT(3)

Check Out this Related Man Page

STREAM_SET_TIMEOUT(3)							 1						     STREAM_SET_TIMEOUT(3)

stream_set_timeout - Set timeout period on a stream

SYNOPSIS
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)
Man Page

13 More Discussions You Might Find Interesting

1. HP-UX

accept problem

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)
Discussion started by: Frank2004
4 Replies

2. Programming

implementing AVL tree

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)
Discussion started by: arjunjag
1 Replies

3. IP Networking

socket programming

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)
Discussion started by: sureshvaikuntam
1 Replies

4. Programming

help regarding socket programming

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)
Discussion started by: abmxla007
1 Replies

5. Linux

socket creation!!!

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)
Discussion started by: sriprasads
0 Replies

6. Programming

and again, socket() related problem...

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)
Discussion started by: sggkxv
1 Replies

7. Programming

How to test a socket conncection in C++ ?

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)
Discussion started by: vij_krr
2 Replies

8. Shell Programming and Scripting

socket programing in client server

(0 Replies)
Discussion started by: saiful_911
0 Replies

9. IP Networking

socket programing-problem with server

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)
Discussion started by: chandinisree
1 Replies

10. Shell Programming and Scripting

How to timeout and proceed in perl?

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)
Discussion started by: Arun_Linux
2 Replies

11. Solaris

weblogic connection timeout error

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)
Discussion started by: core99
0 Replies

12. IP Networking

Read() time out in socket programming

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)
Discussion started by: sanzee007
2 Replies

13. IP Networking

A Basic example of socket programming in C

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)
Discussion started by: yifangt
6 Replies