Toon posts:

socket flush in c

Pagina: 1
Acties:

Verwijderd

Topicstarter
Het idee is vrij simpel.

Op dit moment staat er een servertje in c, welke communiceert met een client in java. Ze krijgen connectie, en de client stuurt iets naar de server.

de server ontvangt dit, past de data aan en stuurt het terug naar de client. Althans...

Dat doet hij pas als je de server afsluit, of in de code de client afsluit.

Nu wil ik graag meteen de data ontvangen aan de client kant, zonder de connectie te verbreken. Het probleem zit hem er in dat de data gebufferd wordt.

Natuurlijk eerst gezocht naar mogelijke oplossingen. Een daarvan is TCP_NODELAY, maar dat werkt niet bij mijn voorbeeld(?).

Wie helpt mij?

  • farlane
  • Registratie: Maart 2000
  • Laatst online: 12-09 23:01
Uit de Unix socket FAQ:
Questions regarding both Clients and Servers (TCP/SOCK_STREAM): How can I force a socket to send the data in its buffer?
From Richard Stevens (rstevens@noao.edu):

You can't force it. Period. TCP makes up its own mind as to when it can send data. Now, normally when you call write() on a TCP socket, TCP will indeed send a segment, but there's no guarantee and no way to force this. There are lots of reasons why TCP will not send a segment: a closed window and the Nagle algorithm are two things to come immediately to mind.

(Snipped suggestion from Andrew Gierth to use TCP_NODELAY)

Setting this only disables one of the many tests, the Nagle algorithm
Zie :
http://www.developerweb.net/sock-faq

en in het bijzonder:
http://www.developerweb.net/sock-faq/detail.php?id=17

Somniferous whisperings of scarlet fields. Sleep calling me and in my dreams i wander. My reality is abandoned (I traverse afar). Not a care if I never everwake.


  • JayTaph
  • Registratie: Oktober 1999
  • Laatst online: 28-11-2025

JayTaph

Portability is for canoes.

Probeer eens een flush() op je socket-handle. Dat zal al veel schelen.

Yo dawg, I heard you like posts so I posted below your post so you can post again.