eof of socketstream?

useo6 isntveryinteresting at isntveryinteresting.com
Wed Jan 25 11:43:37 PST 2012


Nobody knows how to solve that problem? I tried some other solutions where I ran into the same problem:

/* Works as long as bytes available and the length of my buffer is > 1 - doesn't work if the file-size (which
is unknown) has a size which is a multiple of the buffer size... for ex. if the buffer has a size of 128 byte
and the file size is also 128 bytes long and/or is 512 or similar */

while (true) {
	uint num = ss.readBlock(buffer.ptr, buffer.length);
	if (num < buffer.length) break;
}

/* The following works as long as bytes available on the stream - after reading all bytes, the socket blocks */
while (!ss.eof) {
	ss.getc();
}

/* The same like the solutions before... */
while (true) {
	string cLine = cast(string) ss.readLine();
	if (cLine == "") break;
}

I hope anyone can solve the problem... I don't think it's a bug. In my opinion it has something to do with
blocking sockets, but I'm absolutely over-asked why no solution which I found in some other threads doesn't
work...


More information about the Digitalmars-d-learn mailing list