471,353 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

sockets and http

im having a small bug now where if i give a http header GET / with a
connection: keep-alive i cant tell when the server is done sending. If i say
connection: close i dont have a problem. Here is breifly my code.

remember this works fine if i say Connection: close in the http header, if i
say keepalive it does not. anyone know why?

asynch send
------------------------
client.BeginSend(byteData, 0, byteData.Length, 0, new
AsyncCallback(SendCallback), client);
receive event
--------------
int bytesRead = client.EndReceive(ar);
if (bytesRead > 0)
{
//more packets
state.sb.Append(Encoding.ASCII.GetString(state.buf fer,0,bytesRead));
client.BeginReceive(state.buffer,0,StateObject.Buf ferSize,0, new
AsyncCallback(ReceiveCallback), state);
}
else
{
if (state.sb.Length > 1)
{ //its done
response = state.sb.ToString();
receiveDone.Set();
}
}

Michael Evanchik
www.michaelevanchik.com
Jul 21 '05 #1
0 782

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by mrpolitics | last post: by
1 post views Thread by Snyke | last post: by
10 posts views Thread by Cory Nelson | last post: by
7 posts views Thread by Bill English | last post: by
2 posts views Thread by Jm | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.