problem with gc?

zhmt via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 27 18:28:34 PDT 2015


On Wednesday, 27 May 2015 at 19:04:53 UTC, Márcio Martins wrote:
> On Wednesday, 27 May 2015 at 05:48:13 UTC, zhmt wrote:
>> 
>
> The code you posted is the client code, but the issue seems to 
> be on the server side.
> Can you post the server code and also the timing code?


@Márcio Martins

here is the server code:

void echoServer()
{
	Acceptor acc2 = new Acceptor();
	acc2.listen("0.0.0.0",8881,100);
	acc2.accept((Ptr!Conn c){
			scope(exit) c.close();
			
			ubyte[5] buf;
			while(true)
			{
				int n = c.readSome(buf);
				if(n<=0){
					break;
				}
				c.write(buf[0..n]);
			}
			writeFlush("close server sock");
		});
}

and I found the reason:
the buffer size on server is too small, just five,so if the data 
size is more than 5(10000 for example),it will need two read 
operation。

The length of “10000” is 5,it perfectly matched the point of 
falling down。
If change the buffer size to 100, it runs well。

But why it falls sharply down to about 24,I will continue to 
study。


More information about the Digitalmars-d-learn mailing list