473,498 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

speeding up socket connections

i'm trying to write a php script that sends an http request to a
server, get some info. from that server, and print it to the screen.
unfortunately, this script takes longer to connect than i'd like.
replacing the server's ip address with 127.0.0.1 noticeably speeds
things up, but doesn't work if someone's on a virtual host (the paths
would be different).

here's the script i'm using:

<?
$fsock = fsockopen('tcp://ipaddress',80,$errno,$errstr,1);
fputs($fsock,"GET /filename.txt HTTP/1.0\r\n");
fputs($fsock,"Host: domain.com\r\n\r\n");
while (!feof($fsock))
echo fgets($fsock);
fclose($fsock);
?>

i'm aware that fopen would work in this particular case, but in the
context of what i'm trying to do, it doesn't (i don't, ultimately, want
to get the contents - i just want to send an http request and be done
with it, for the purposes of initiating time consuming tasks such as
backups in safe mode, without requiring the user wait for the task to
complete).

any ideas as to how i could speed the above code up?

alternatively, any ideas how, when ipaddress is replaced with
127.0.0.1, the path on the domain that's being requested could be
adjusted to the real host (as opposed to the virtual one)?

Jul 17 '05 #1
1 1309
"yawnmoth" <te*******@yahoo.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
i'm aware that fopen would work in this particular case, but in the
context of what i'm trying to do, it doesn't (i don't, ultimately, want
to get the contents - i just want to send an http request and be done
with it, for the purposes of initiating time consuming tasks such as
backups in safe mode, without requiring the user wait for the task to
complete).


Just because your fopen() a URL doesn't mean you have to get the contents.
Hint: don't call fread().
Jul 17 '05 #2

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

Similar topics

9
11318
by: AA | last post by:
This is making me crazy!! Please, if some body can help me. I'm testing a ver simple socket client. In my test I just open and close a connection (in a loop) to my local IIS server (port 80)...
4
18084
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed...
2
6857
by: Macca | last post by:
My app has an asynchronous socket server. It will have 20 clients connected to the server. Each client sends data every 500 millisecondsThe Connections once established will not be closed unless...
0
4647
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a...
5
4739
by: zxo102 | last post by:
Hi, I am doing a small project using socket server and thread in python. This is first time for me to use socket and thread things. Here is my case. I have 20 socket clients. Each client send a...
4
3590
by: Engineerik | last post by:
I am trying to create a socket server which will listen for connections from multiple clients and call subroutines in a Fortran DLL and pass the results back to the client. The asynchronous socket...
5
12746
by: darthghandi | last post by:
I've created a class to listen to all interfaces and do a BeginAccept(). Once it gets a connection, it passes the connected socket off and stores it in a List. Next, it continues to listen for...
11
8578
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling...
14
5886
by: =?Utf-8?B?TWlrZVo=?= | last post by:
I have a sync socket application. The client is blocked with Socket.Receive(...) in a thread, another thread calls Socket.Close(). This unblock the blocked thread. But the socket server is still...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
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...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
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,...
0
4590
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...
0
3093
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...
0
1419
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 ...
1
656
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.