| View previous topic :: View next topic |
| Author |
Message |
Keith Maclaine
Joined: 23 Jun 2006 Posts: 12
|
| Hi everybody , i have one question about HTTP/1.1 persistante connections .. if i have connection to server, the connection is in state open , the server sends me the FIN packet what should i do then ? I mean sending back FIN/ACK is the work of java librarys not ? |
| |
|
|
|
|
BigDaddy
Joined: 26 May 2006 Posts: 147
|
Keith Maclaine, it depends...
do you close the connection?
do you work with sockets or URLConnection? |
| |
|
|
Keith Maclaine
Joined: 23 Jun 2006 Posts: 12
|
| BigDaddy , well i dont close connection after sending some request becouse of this should be persistante conn. |
| |
|
|
BigDaddy
Joined: 26 May 2006 Posts: 147
|
hard to keep it persistent if the server closes...
but still, are you using sockets or URLConnection |
| |
|
|
Keith Maclaine
Joined: 23 Jun 2006 Posts: 12
|
| yes , sockets |
| |
|
|
BigDaddy
Joined: 26 May 2006 Posts: 147
|
writing correct http/1.1 socket code is quite hard...
why not use an existing library?
URLConnection uses persistent connections if it can. My proxy does it as well, commons net from apache probably does to |
| |
|
|
Keith Maclaine
Joined: 23 Jun 2006 Posts: 12
|
| well my question is what is has to be done when my app receives for any reason FIN packet from server |
| |
|
|
BigDaddy
Joined: 26 May 2006 Posts: 147
|
| you will get a read() that returns -1 (EOF) |
| |
|
|
Keith Maclaine
Joined: 23 Jun 2006 Posts: 12
|
| BigDaddy, so the solution is to call a read() all the time ? |
| |
|
|
BigDaddy
Joined: 26 May 2006 Posts: 147
|
no...
are you using blocking io or selector based non-blocking io? |
| |
|
|
Keith Maclaine
Joined: 23 Jun 2006 Posts: 12
|
| blocking |
| |
|
|
|
|
BigDaddy
Joined: 26 May 2006 Posts: 147
|
| then you have one thread that reads from each socket and then you do call read all the time |
| |
|
|
|