Re: [xSocket-develop] Close socket after data sent
Status: Inactive
Brought to you by:
grro
|
From: Gregor R. <gre...@go...> - 2009-01-19 06:58:49
|
Hi Amine, xSocket give you 3 options to send data. By default the write operation will be synchronous, that means the write call returns after the data is written (into the OS-internal SO_SNDBUF). If you set the FlushMode to async, the write method will return immediately. The write operation(s) will be done in the background. xSocket uses an internal second-level buffer to do this. If you have written a large amount of data and you closes the connection, xSocket tries to flush all the data of the second-level buffer before the connection will be closed physically. If you want to avoid large second-level write buffer or to have more control over the flowcontrol, you can use xSocket's IWriteCompletionHandler support. Please see chapter 25 of the tutorial. Gregor 2009/1/18 Amine Haddad <ami...@gm...> > Hi Gregor, > > Thank you for the prompt reply. I have a problem with this logic - what > happens if the data in the queue is larger than your connection can spare? > For example, the data in the queue is 1MB and you can only send 10KB/s, and > I call the close() method? > > Amine > > > On Sun, Jan 18, 2009 at 12:08 PM, Gregor Roth <gre...@go...>wrote: > >> Hi Amine, >> >> if you close the connection, all data of the write queue will be flushed >> automatically. This is especially true for flushMode Async. If you write >> data in (default) flushMode Sync, the write method returns only if the data >> ids written. >> >> Gregor >> >> >> 2009/1/18 Amine Haddad <ami...@gm...> >> >>> Hello, >>> >>> How am I able to close a non-blocking connection only after all the data >>> queued to be sent has been sent? I am using xSocket-2.3.2. >>> >>> Thanks, >>> Amine >>> >>> >>> ------------------------------------------------------------------------------ >>> This SF.net email is sponsored by: >>> SourcForge Community >>> SourceForge wants to tell your story. >>> http://p.sf.net/sfu/sf-spreadtheword >>> _______________________________________________ >>> xSocket-develop mailing list >>> xSo...@li... >>> https://lists.sourceforge.net/lists/listinfo/xsocket-develop >>> >>> >> > |