Solved

Peek into blocking sockets?

Posted on 2002-06-03
4
879 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Checking CSRF token within a function 36 74
How to properly use session_regenerate_id when user logs in 7 37
php convert date format 3 21
php simple error message 4 23
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

776 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