473,226 Members | 1,569 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,226 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 2151
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.