Einzelnen Beitrag anzeigen
Alt 18.06.2007, 21:29   #2
jak
Inventar
 
Registriert seit: 13.06.2001
Beiträge: 1.830


Standard

Kurz gesagt: Weil read blocking ist.

Erklärung: Der .read() Befehl blockiert solange bis es etwas zu lesen gibt. Das der Server inzwischen den Socket geschlossen hat bekommt er nicht mit.
Zitat:
This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.
Quelle: JavaDoc http://java.sun.com/javase/6/docs/ap...ream.html#read()

Die einzigen Möglichkeiten die ich kenne das zu vermeiden sind:
1.) Der Client weiß wie viele Zeichen er noch lesen darf ohne das .read() blockiert (siehe auch .available()).
2.) Es gibt einen Code oder ein Zeichen das das Ende der Übertragung anzeigt (z.B. '.' beim SMTP Protokoll).

jak
____________________________________
Join the DNRC | Godwin\'s Law (thx@stona)
Documentation is like sex: If it\'s good, it\'s very, very good. If it\'s bad, it\'s better than nothing.
\"In theory, theory and practice are the same. In practice, they are not\" (Lawrence Berra)
jak ist offline   Mit Zitat antworten