473,544 Members | 1,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems using fsockopen, stream_set_time out and fgets


I'm communicating with a server using UDP, and it can be
narrowed down to this:

$us = 75000; //Timeout in microseconds.
$con = fsockopen("udp://127.0.0.0","230 00");
stream_set_time out($con,0,$us) ;
fwrite($con"\xf f\info\");
$retval = fgets($con,1024 0);

My problem is that I allways have to wait for $us seconds.
So if I set it to 2 seconds, I have to wait for 2 seconds.
And if I set it to low, I might not wait long enough to get
an answer. So I've ended up using 0.075 seconds, which isn't
all that much. But I'd much rather find another way of
doing this, so that I can set the timeout as high as I like,
and still not have to wait longer than it takes to actually
retrieve the data.

Would reading one byte at a time, and check the last recieved
bytes for a known pattern resolve this...? Any suggestions?

-Fred

P.S. I haven't been able to play around and try different things
with this yet, due to deadlines on a couple of other projects...

--
Fred H

void FredH::Contact( ) {
TextToSpeach.sa y("frode at age dee dee dot en oh");
}
Jul 17 '05 #1
2 5806
On Mon, 23 Feb 2004 14:58:01 +0000, Fred H wrote:
I'm communicating with a server using UDP, and it can be narrowed down to
this:

$us = 75000; //Timeout in microseconds. $con =
fsockopen("udp://127.0.0.0","230 00"); stream_set_time out($con,0,$us) ;
fwrite($con"\xf f\info\");
$retval = fgets($con,1024 0);


I don't see any reason to use stream_set_time out() with UDP since UDP is
connectionless. Sometimes, fsockopen() won't even tell you that something
went wrong; you'll find this out reading/writing to the resource.

I say try working with it without the timeout. Look for errors using
fwrite()/fgets() and then take the appropriate decisions.

--
Daniel
Jul 17 '05 #2
> I don't see any reason to use stream_set_time out() with UDP since UDP is
connectionless. Sometimes, fsockopen() won't even tell you that something
went wrong; you'll find this out reading/writing to the resource.
But if I read, and there is nothing to read, won't I just hang if I haven't
set a timeout...?
I say try working with it without the timeout. Look for errors using
fwrite()/fgets() and then take the appropriate decisions.


Doesn't work. It just hangs...

--
Fred H

void FredH::Contact( ) {
TextToSpeach.sa y("frode at age dee dee dot en oh");
}
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4716
by: Michael T. Peterson | last post by:
I am trying to get the file referenced by the following url: http://waterdata.usgs.gov/wa/nwis/uv?dd_cd=01&dd_cd=02&format=rdb&period=1&site_no=12149000 I'm using parse_url to get the host, path, and query. My call to fsockopen() works correctly. Unfortunately, I can find no documentation for how to construct a request that will...
2
3312
by: Colin Bell | last post by:
I'm stuck on a problem with getting data from a XML data stream. This stream is large and trying to use fsockopen to get the stream down. I've tetsed the code by telneting into the machine/port but I am getting some of the data but not all. I don't know the stream size. Code snippit below: function txrx($server, $port, $tx){
1
3124
by: chaos | last post by:
Hello, i have problems using sqlj in the following environment. I use type 4 driver com.ibm.db2.jcc.DB2Driver and connect succesful to 8.1. db2-Database(DRDA)(Informational tokens are "DB2 v8.1.0.32", "s031027", "MI00060", and FixPak "4".Product is installed at "/opt/IBM/db2/V8.1"). It runs in an applicationcontainer (jdk1.4, linux). I...
2
2354
by: Paul Duncan | last post by:
diggityduncs (Programmer) Nov 13, 2003 Hello, I'm tring to use a win32/api dll in c# The vendor I received the dll from doesn't know anything about .net I received two files ACGAPI.DLL +
1
2675
by: Skeets | last post by:
i'm having some php problems. i have the following code on my main page: ------------ $fp = fsockopen("127.0.0.1", 49152, $errno, $errrstr, 30); if (!$fp) { echo "socket error: $errstr ($errno)<br />\n"; die;
3
8482
by: Aetherweb | last post by:
Hi, I need to use fsockopen to open a connection, send a GET request and read in the response. At the moment I'm trying the following code, but I think it's ignoring the actual URL included in the $request variable. $host = "www.myhost.com"; $request = "/myurl.php?param1=1&param2=2&param3=3";
24
2899
by: allpervasive | last post by:
hi all, this is reddy, a beginner to c lang,,here i have some problems in reading and modifying the contents of a file,, hope you can help to solve this problem. Here i attach the file to be modified and the program code. In the attached file below i just want to change the value of data(only float value) after the line 1 P V T 1 15 till 2...
3
13429
by: Brett R. Wesoloski | last post by:
I am having problems using HttpContext.Current.Request.Url.Host. I have some code that does this... if (HttpContext.Current != null) { subdomain = HttpContext.Current.Request.Url.Host; }
2
2172
by: haytham2008 | last post by:
hi every body i have this problem while i trying to send email using php i found a function <?php mail(); ?> but does not work with me since i use smtp server with user name and password
0
7368
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7777
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5916
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5301
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3420
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3414
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1844
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
990
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.