G
Guest
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.buffer,0,bytesRead));
client.BeginReceive(state.buffer,0,StateObject.BufferSize,0, new
AsyncCallback(ReceiveCallback), state);
}
else
{
if (state.sb.Length > 1)
{ //its done
response = state.sb.ToString();
receiveDone.Set();
}
}
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.buffer,0,bytesRead));
client.BeginReceive(state.buffer,0,StateObject.BufferSize,0, new
AsyncCallback(ReceiveCallback), state);
}
else
{
if (state.sb.Length > 1)
{ //its done
response = state.sb.ToString();
receiveDone.Set();
}
}