473,418 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

How to know when an HTTP page is complete

I'm doing a "low level" server with sockets and trying to read the HTTP
data from server.
socket.Available at the beginning is 0 and I don't know when an HTTP
page is completly read since socket.Available sometimes is 0 and the
pages don't return the Content-Length field in the HTTP header.

How can I know when an HTTP page is complete? How does Internet
Explorer or Mozilla Firefox implements this procedure?

Any hints? Here's my simple code to retrieve the data after I connect
to the server:

**************************************************
byte[] msg=Encoding.UTF8.GetBytes("GET / HTTP/1.1\n\n");
byte[] bytes=new byte[65536];
int i=socket.Send(msg,0,msg.Length,SocketFlags.None);
MessageBox.Show("Sent "+i.ToString()+" bytes. Available:
"+socket.Available.ToString()+" bytes.");
socket.Receive(bytes,0,socket.Available,SocketFlag s.None);
TrafficLogTextBox.Text+=Encoding.UTF8.GetString(by tes);
TrafficLogTextBox.Text+="\r\n";
MessageBox.Show(Encoding.UTF8.GetString(bytes));

Nov 26 '05 #1
4 2164
Why don't you use WebClient/WebRequest or any other high level method to
connect to the site?

"Nuno Magalhaes" <nu************@hotmail.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...
I'm doing a "low level" server with sockets and trying to read the HTTP
data from server.
socket.Available at the beginning is 0 and I don't know when an HTTP
page is completly read since socket.Available sometimes is 0 and the
pages don't return the Content-Length field in the HTTP header.

How can I know when an HTTP page is complete? How does Internet
Explorer or Mozilla Firefox implements this procedure?

Any hints? Here's my simple code to retrieve the data after I connect
to the server:

**************************************************
byte[] msg=Encoding.UTF8.GetBytes("GET / HTTP/1.1\n\n");
byte[] bytes=new byte[65536];
int i=socket.Send(msg,0,msg.Length,SocketFlags.None);
MessageBox.Show("Sent "+i.ToString()+" bytes. Available:
"+socket.Available.ToString()+" bytes.");
socket.Receive(bytes,0,socket.Available,SocketFlag s.None);
TrafficLogTextBox.Text+=Encoding.UTF8.GetString(by tes);
TrafficLogTextBox.Text+="\r\n";
MessageBox.Show(Encoding.UTF8.GetString(bytes));

Nov 26 '05 #2
Because I'm doing a project that consists on logging certain parameters
of QoS as Time to Resolve DNS, Time To Connect, Time To Receive Data,
etc...

Any hints on how can I know if a web page is complete (note: I don't
always get the content-length parameter in the response header).

How does IE or Mozilla implements this procedure... how does it know
when a page is completly read?

Thank for any reply,
Nuno Magalhaes.

Nov 27 '05 #3
Nuno Magalhaes wrote:
Because I'm doing a project that consists on logging certain
parameters of QoS as Time to Resolve DNS, Time To Connect, Time To
Receive Data, etc...

Any hints on how can I know if a web page is complete (note: I don't
always get the content-length parameter in the response header).

How does IE or Mozilla implements this procedure... how does it know
when a page is completly read?


Read the spec: http://www.w3.org/Protocols/rfc2616/rfc2616.html.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 27 '05 #4
WRH
Hello
Perhaps something like
while(socket.Receive(bytes,0,socket.Available,Sock etFlags.None) != 0)
with a time out may work
"Nuno Magalhaes" <nu************@hotmail.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...
I'm doing a "low level" server with sockets and trying to read the HTTP
data from server.
socket.Available at the beginning is 0 and I don't know when an HTTP
page is completly read since socket.Available sometimes is 0 and the
pages don't return the Content-Length field in the HTTP header.

How can I know when an HTTP page is complete? How does Internet
Explorer or Mozilla Firefox implements this procedure?

Any hints? Here's my simple code to retrieve the data after I connect
to the server:

**************************************************
byte[] msg=Encoding.UTF8.GetBytes("GET / HTTP/1.1\n\n");
byte[] bytes=new byte[65536];
int i=socket.Send(msg,0,msg.Length,SocketFlags.None);
MessageBox.Show("Sent "+i.ToString()+" bytes. Available:
"+socket.Available.ToString()+" bytes.");
socket.Receive(bytes,0,socket.Available,SocketFlag s.None);
TrafficLogTextBox.Text+=Encoding.UTF8.GetString(by tes);
TrafficLogTextBox.Text+="\r\n";
MessageBox.Show(Encoding.UTF8.GetString(bytes));

Nov 27 '05 #5

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

Similar topics

3
by: Steven Scaife | last post by:
I have a search page with upteen boxes that they can choose to fill out and my second page gets the values and passes them to a stored procedure which builds the SQL string and returns the...
8
by: Andrew Phillipo | last post by:
I have a layout which works perfectly. It is three column, the central column is width:auto; with margins and the columns are absolutely positioned at top:0px; left:0px; and top:0px;right:0px; ...
6
by: Peter Row | last post by:
Hi, I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest. This code calls a sub and I need to know if that sub did a response redirect or not. Specifically I need to know...
12
by: urs | last post by:
Hi, please look at the ASP.NET 2 site http://www.prismatest.ch/catalog/EM.ASPX (user=prismashop, password=minicooper). Use the ">" Button to go to the next pages. You will notice that the page...
6
by: JohnR | last post by:
I'm running into a 'timing' or 'race' condition on my form. All textbox controls are bound to a datasource, but certain other controls (like labels) need to be updated when you move to a...
1
by: VMI | last post by:
I wrote a web service whose only purpose is to update a field in a table (sql server). And everything works except for the browser window that opens up with "The page cannot be displayed" error...
9
by: Coleen | last post by:
Hi All :-) I am desperately looking for some help/information on how to direct page flow. Forget what I have done - here's what I need to do: I have a large ASPX.Net - VB.Net web application...
1
by: JimO | last post by:
I'm trying to write an ASP interface that mimiks a .Net datagrid control. I'm having a problem when I'm in the middle of an Edit, Update, or a New Record. If the user hits the wrong button, the...
13
by: Davo | last post by:
Hi Folks, There seems to be something about not using tables for layout, but use divs instead. I'm not sure if I've got this right. If the output looks like what you want, then it shouldn't...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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
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...
0
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...

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.