tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastian Klenk <sebastiankl...@visions-tec.de>
Subject Re: RES: TCP-FIN problem
Date Tue, 23 Dec 2003 17:18:36 GMT
Maybe with a little bit more detail:


Application Code:

....
....

	try {
		
			ClientSocket = new Socket(IPAddress, Port);
			Sender = new OutputStreamWriter(ClientSocket.getOutputStream());
			Reciever = new InputStreamReader(ClientSocket.getInputStream());

			
		} catch (UnknownHostException e) {
			 System.err.println("Unknown host: " + IPAddress);
		} catch(IOException e){
			 System.err.println("IOException: " + IPAddress + " -> " + 
e.getMessage());
		}

.....
.....
.....



	    String Message = new String(Method + " " + File +" HTTP/1.1\r\n");
             Sender.write(Message,0,Message.length());

             /* HOST */
             Message = new String("Host: "+ IPAddress +":" + Port + "\r\n");
             Sender.write(Message,0,Message.length());

             Message = new String("Content-Type: text/xml\r\n");
             Sender.write(Message,0,Message.length());

             Message = new String("Content-length: 
"+Data.length()+"\r\n\r\n");
             Sender.write(Message,0,Message.length());
             Sender.write(Data,0,Data.length());

             Sender.flush();

.....
.....
.....



         try {

             int c;
             while(-1 != (c = Reciever.read()))
                 XMLBuffer.append((char)c);

         }catch (EOFException e){
         }catch (Exception e) {
             System.out.println("getServer() : Exception Cought: " + 
e.getMessage());
             return null;
             }





Servlet code could look like this



     public void doGet(HttpServletRequest request, HttpServletResponse 
response)
             throws IOException, ServletException {

....
....
....

             try{
 
Data.getDataSQL(JDBCDriver,JDBCPath,JDBCUser,JDBCPasswd,Edit);
             }catch(Exception e){
                 getLogger().writeToLog("Database Read Statement Error: 
" + e.toString() + " -> " + Edit);
                 }
             response.getWriter().print(Data);
             response.setContentLength(Data.toString().length());
             }


Hope this makes all a little bit clearer!


Philipp Taprogge wrote:
> Hi!
> 
> Sebastian Klenk wrote:
> 
>> I didn't do anything ... the only problem I have is that my app. is 
>> not very fast, and that is because it has to wait for tomcat to close 
>> the connection, but tomcat closes the connection a lot later (ca 1 
>> minute).
>> My question is now if there is a way to tell tomcat that all data has 
>> been written an that the connection can be closend!?
> 
> 
> Your problem is not tomcat, but the application. Tomcat uses a default 
> timeout of 60 seconds on the socket. But what seems to happen in your 
> case is not tomcat causing that timeout, but _experiencing_ it.
> Your application is not closing the connection properly and tomcat keeps 
> it open until the timeout occurs. Could you perhaps post more 
> information on that application? Is it written in Java as well? Perhaps 
> you could post some code snipplets?
> 
>     Phil
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message