Solved

Peek into blocking sockets?

Posted on 2002-06-03
4
884 Views
Last Modified: 2008-03-10
Is there a way to find out whether there is data waiting in the buffer of a blocking socket? I need to read out data if it's there, or don't if it's not. Problem with blocking sockets is that once you've begun a read operation, it does not return before that many bytes are actually read, which becomes a problem if those bytes never arrive, since your script just hangs.

I've tried socket_get_status(), which says that it returns the number of unread bytes in the socket buffer, but instead it always returns 0.

I've tried to set the sockets to non-blocking, but I don't really know how to use them that way.

Can anybody help?
0
Comment
Question by:nrico
4 Comments
 

Accepted Solution

by:
mrvithan earned 200 total points
ID: 7064115
you might be looking for socket_select function; http://www.php.net/manual/en/function.socket-select.php

try it
0
 
LVL 11

Expert Comment

by:shmert
ID: 9643223
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept mrvithan
Please leave any comments here within the next seven days.
               
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question