Solved

Peek into blocking sockets?

Posted on 2002-06-03
4
890 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

732 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