N
Nuno Magalhaes
I've got a problem which relates to reading HTTP data.
I've got the socket connected to a web site and then I send "GET /
HTTP/1.1\n\n" and the page is received after a while but not all of the
page. Should I implement a timer to read the web page? How do I know
when the page is completed if sometimes socket.Available is 0?
The procedure is as follows:
-Socket socket=new
Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
-socket.Connect(endpoint);
-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,SocketFlags.None);
TrafficLogTextBox.Text+=Encoding.UTF8.GetString(bytes);
TrafficLogTextBox.Text+="\r\n";
MessageBox.Show(Encoding.UTF8.GetString(bytes));
How does HTTPWebResponse implements this? Does it use a timer between
non receiving data times? *How do I know when the page is complete?*
Did I made myself clear?
Thanks a lot,
Nuno Magalhaes.
I've got the socket connected to a web site and then I send "GET /
HTTP/1.1\n\n" and the page is received after a while but not all of the
page. Should I implement a timer to read the web page? How do I know
when the page is completed if sometimes socket.Available is 0?
The procedure is as follows:
-Socket socket=new
Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
-socket.Connect(endpoint);
-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,SocketFlags.None);
TrafficLogTextBox.Text+=Encoding.UTF8.GetString(bytes);
TrafficLogTextBox.Text+="\r\n";
MessageBox.Show(Encoding.UTF8.GetString(bytes));
How does HTTPWebResponse implements this? Does it use a timer between
non receiving data times? *How do I know when the page is complete?*
Did I made myself clear?
Thanks a lot,
Nuno Magalhaes.