views:

27

answers:

2

Hi guys

I'm building a client that "talks" to the http server. Now my client needs to download files simultaneously. Right now my client just opens a socket (actually Async Socket) for every connection, but I was wondering whether I could do that with just one socket?

Thanks

Alex

A: 

You can have multiple requests on the same socket but they must be sequentially handled. In HTTP this is called a persistent connection and you can accomplish it using the keep-alive header.

If you want to download 2 files individually at the same time you'd need 2 separate connections.

Brian R. Bondy
Can you elaborate on the keep-alive thing? Isn't it the default in http 1.1?
Alex1987
@Alex1987: If I remember correctly the keep-alive is defaulted to keep alive but can also be set to Close.
Brian R. Bondy
A: 

Take a look at RFC 2616 section 8 "Connections".

Nikolai N Fetissov