Re: NSFileHandle readInBackground vs threading?

2011-11-13 Thread Alexander Bokovikov
On 09.11.2011, at 19:25, Scott Ribe wrote: I'm not arguing the OP isn't seeing data lost, just that it cannot be happening the way he thinks it is if he's using any normal networking calls. Thanks to everybody for your useful comments! My local socket is opened in the client process just a

Re: NSFileHandle readInBackground vs threading?

2011-11-09 Thread Scott Ribe
On Nov 8, 2011, at 11:45 PM, Kyle Sluder wrote: > The kernel only has a certain amount of buffer space dedicated to each > incoming TCP port. If the port gets flooded, it drops packets. But this is TCP: 1) Flow control should generally prevent buffers from being overrun; 2) Even if packets are

Re: NSFileHandle readInBackground vs threading?

2011-11-09 Thread Andreas Grosam
On Nov 8, 2011, at 5:54 PM, Alexander Bokovikov wrote: > I have a need to read some data from a local socket, which serves for IPC. > And data may come very quickly, so (AFAIU) inner socket buffer might > overflow, so a portion of data might be lost. This has been answered by previous posters

Re: NSFileHandle readInBackground vs threading?

2011-11-09 Thread Don Quixote de la Mancha
Keep pointers to your packetBuffers in a circular buffer. When a new packet comes in, add it to the front of the buffer. When you're ready to process a packet, remove it from the end of the buffer. Some testing should determine how big your buffer needs to be. On anything but a real-time operat

Re: NSFileHandle readInBackground vs threading?

2011-11-08 Thread Ken Thomases
On Nov 9, 2011, at 12:45 AM, Kyle Sluder wrote: > On Tue, Nov 8, 2011 at 9:43 PM, Scott Ribe > wrote: >> I assume by "local socket" you mean either a UNIX domain socket or just a >> regular TCP socket on the local machine? If so, just using regular read & >> write calls there's no way for data

Re: NSFileHandle readInBackground vs threading?

2011-11-08 Thread Kyle Sluder
On Tue, Nov 8, 2011 at 9:43 PM, Scott Ribe wrote: > I assume by "local socket" you mean either a UNIX domain socket or just a > regular TCP socket on the local machine? If so, just using regular read & > write calls there's no way for data to be lost & not delivered just because > it's consumed

Re: NSFileHandle readInBackground vs threading?

2011-11-08 Thread Scott Ribe
On Nov 8, 2011, at 10:02 PM, Alexander Bokovikov wrote: > Sometimes data are lost when they come with high speed. I assume by "local socket" you mean either a UNIX domain socket or just a regular TCP socket on the local machine? If so, just using regular read & write calls there's no way for da

Re: NSFileHandle readInBackground vs threading?

2011-11-08 Thread Alexander Bokovikov
On 09.11.2011, at 0:50, Scott Ribe wrote: On Nov 8, 2011, at 9:54 AM, Alexander Bokovikov wrote: I have a need to read some data from a local socket, which serves for IPC. And data may come very quickly, so (AFAIU) inner socket buffer might overflow, so a portion of data might be lost. W

Re: NSFileHandle readInBackground vs threading?

2011-11-08 Thread Scott Ribe
On Nov 8, 2011, at 9:54 AM, Alexander Bokovikov wrote: > I have a need to read some data from a local socket, which serves for IPC. > And data may come very quickly, so (AFAIU) inner socket buffer might > overflow, so a portion of data might be lost. What makes you think that? If the buffers f

NSFileHandle readInBackground vs threading?

2011-11-08 Thread Alexander Bokovikov
Hi, All, I have a need to read some data from a local socket, which serves for IPC. And data may come very quickly, so (AFAIU) inner socket buffer might overflow, so a portion of data might be lost. I don't see a way how to define an inner system buffer size, so the only I can is to do my