<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2745.2800" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2>Hello,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I am attempting to "perfect" a socket driver which
will received lines of text from another system.</FONT></DIV>
<DIV><FONT face=Arial size=2>The heart of the code, without the initial sockets
opening instructions and debug messages is shown below.</FONT></DIV>
<DIV><FONT face=Arial size=2>Messages are received from the other system but the
timeout isn't working properly. </FONT></DIV>
<DIV><FONT face=Arial size=2>The results I get when no data is being
transmitted from the other end is:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>1. The read is completed several times but the
buffer is empty and the time from before to after the read is zero i.e. it
completes the read instantly.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>2. I then get a couple of reads which wait for 10
seconds each returning an empty string. (This is almost what I
want)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>3. Return to step 1.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I would expect the read to timeout after 30
seconds, return an empty buffer and then wait for another 30
seconds.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Any suggestions much appreciated.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Brendan Whelan</FONT></DIV>
<DIV><FONT face=Arial
size=2>----------------------------------------------------------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2>while ($continue == "Y")<BR>{<BR>
if ($conn != "")<BR> {<BR>
$result = socket_close($conn);<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> $conn =
socket_accept($sock);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>
support_f_socket_timeout($conn);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> $received = socket_read($conn,
4096);<BR>}<BR>--------------------------------------------------------------------------------------<BR>
function support_f_socket_timeout($conn)<BR> {<BR>// Set the logic
to wait for the read to complete or the timer to
expire<BR> if (! $return =
@socket_set_block($conn))<BR>
{<BR> $last_error =
socket_last_error();<BR>
support_f_socket_report_error($receive_or_send, $debug, $last_error,
<BR> "Unable to set non
block");<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>// Set a time delay - NOTE: Hard coded in the
call<BR> if (! $return = socket_set_option($conn,
SOL_SOCKET, SO_RCVTIMEO,
array("sec"=>30,"usec"=>0)))<BR>
{<BR> $last_error =
socket_last_error();<BR>
support_f_socket_report_error($receive_or_send, $debug, $last_error,
<BR> "Unable to set timeout
option");<BR> }<BR>
}</FONT></DIV></FONT></DIV></BODY></HTML>