readblock

Over TCP communication in C, how can you indicate to stop calling read() for a request without knowing any prior information about the data?

怎甘沉沦 提交于 2020-01-11 13:20:12
问题 I am currently programming a server in C that communicates over sockets using TCP. The client is supposed to send {filename\n} + {file contents\n} and the server will store that information and then send a response on success. However, we can't be sure the client will actually send the proper information in a structured protocol. Often in simpler situations, we know a specified amount of bytes to be sent before and can wait until that specified number has been reached. In this case, we don't

When to use StreamReader.ReadBlock()?

人盡茶涼 提交于 2019-11-30 12:07:51
I would like to know of a situation Read(char[],int,int) fails to return all chars requested while ReadBlock() returns all chars as expected (say when StreamReader works with an instance of a FileStream object). In practice, when using a StreamReader it is only likely to happen with a stream which may delay for some time - e.g. a network stream as people have mentioned here. However, with a TextReader generally, you can expect it to happen at any time (including possibly with a future version of .NET in a case where it doesn't currently happen - that it doesn't happen with StreamReader backed

When to use StreamReader.ReadBlock()?

你。 提交于 2019-11-29 18:01:18
问题 I would like to know of a situation Read(char[],int,int) fails to return all chars requested while ReadBlock() returns all chars as expected (say when StreamReader works with an instance of a FileStream object). 回答1: In practice, when using a StreamReader it is only likely to happen with a stream which may delay for some time - e.g. a network stream as people have mentioned here. However, with a TextReader generally, you can expect it to happen at any time (including possibly with a future