Frage

Verwenden der Methode 'bekommt' wiederholt auf einem TCPSocket-Objekt, erhalte ich den folgenden Ausgang generasacodicetagpre.

Wenn ich wieder benutze, alles hängt, hängt, wie würde ich diesen "Inhalt" der Länge 45 erhalten?Kann ich dies von meinem TCPSocket-Objekt bekommen oder muss ich etwas anderes verwenden?

War es hilfreich?

Lösung

gets reads a line, so it will block until the connection times out or it reads a newline character. You should use the read method, which reads a given number of bytes (which is very conveniently provided in the Content-Length header).

Andere Tipps

Include the header:

Connection: close

to the header. This will prevent the hanging before actually reading the body of the request.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top