473,320 Members | 2,177 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,320 software developers and data experts.

sockets and http question

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();
}
}
Nov 17 '05 #1
4 1256
Michael Evanchik wrote:
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?

[snip]

Question: Why are you using TcpClient instead of WebRequest? This means
you must also implement all low-level TCP connection handling
faithfully according to the HTTP spec, which might be the problem here.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #2
im not using either im using system.net sockets lowest level the framework
will let me

"Joerg Jooss" wrote:
Michael Evanchik wrote:
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?

[snip]

Question: Why are you using TcpClient instead of WebRequest? This means
you must also implement all low-level TCP connection handling
faithfully according to the HTTP spec, which might be the problem here.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de

Nov 17 '05 #3
how about why not? i have microsofts pre made object but was having trouble
with cookies etc see
http://www.microsoft.com/communities...xp=&sloc=en-us

also my question kind of got answered here
http://www.experts-exchange.com/Prog....html#14090121
what do you think?

"Joerg Jooss" wrote:
Michael Evanchik wrote:
im not using either im using system.net sockets lowest level the
framework will let me


Ah, guessed wrong ;-)

The question remains, though -- why?

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de

Nov 17 '05 #4
Michael Evanchik wrote:
how about why not? i have microsofts pre made object but was having
trouble with cookies etc see
http://www.microsoft.com/communities...fault.aspx?que
ry=httpwebresponse+evanchik&dg=&cat=en_US_850c4b7a-113f-45f2-93ff-9d21
e03b29f3&lang=en&cr=&pt=&catlist=&dglist=&ptlist=& exp=&sloc=en-us
OK, now I do remember that thread ;-)

But what about the code I posted? No good?

also my question kind of got answered here
http://www.experts-exchange.com/Prog...Languages/C_Sh
arp/Q_21437151.html#14090121

what do you think?


That this doesn't answer anything. And that this is only shows the
complexity of what you need to deal with if you try this stuff at
socket level.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #5

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

Similar topics

4
by: 0to60 | last post by:
I have a question about socket programming in general. Exactly what happens behind the scenes when I one socket connects to a different socket in listen mode? Using the dotnet framework, I...
7
by: Bill English | last post by:
How do I send an object from one computer to another? -- I am a 14 year old C# developer, I am completely self taught, so please don't get mad if I ask a stupid question. Thanks.
2
by: ZorpiedoMan | last post by:
I'm new to the world of sockets, and this question is not VB specific: If multiple clients access the same server on the same port, and the server is set up to do some async communication, does...
4
by: Sueffel | last post by:
Boy, someday I may get good at this stuff! Until then, I have a "TCP server" that accepts multiple connections. That all works wonderfully! YEAH!!!! I have a TCPClient that is the client...
15
by: mrpolitics | last post by:
So I'm working with PureIRCD (http://sourceforge.net/projects/pure-ircd) and everything was fine untill yesterday when the server crashed. So I did a cold restart and staretd the server back up...
3
by: derSchweiz | last post by:
Hi, Experimenting with sockets, and I think I got it half working. I have the following code: Private Sub socket_receive(ByVal sender As Object, ByVal e As System.EventArgs) Handles...
14
by: eliss.carmine | last post by:
I'm using TCP/IP to send a Bitmap object over Sockets. This is my first time using C# at all so I don't know if this is the "right" way to do it. I've already found out several times the way I was...
0
by: rossabri | last post by:
This topic has been addressed in limited detail in other threads: "sockets don't play nice with new style classes :(" May 14 2005....
3
by: Daniel | last post by:
Hello, I can't seem to get my sockets code to work right. Here is what I have inside my RequestHandler handle() function: total_data= data = True...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.