Re: Socket server + thread: cpu usage

2014-05-01 Thread Tim via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 17:19:41 UTC, Adam D. Ruppe wrote: On Tuesday, 29 April 2014 at 17:16:33 UTC, Tim wrote: Is there anything I'm doing wrong? You should be using a blocking socket. With them, the operating system will put your thread on hold until a new connection comes in.

Re: Socket server + thread: cpu usage

2014-05-01 Thread Tim via Digitalmars-d-learn
On Thursday, 1 May 2014 at 08:08:37 UTC, Tim wrote: On Tuesday, 29 April 2014 at 17:19:41 UTC, Adam D. Ruppe wrote: On Tuesday, 29 April 2014 at 17:16:33 UTC, Tim wrote: Is there anything I'm doing wrong? You should be using a blocking socket. With them, the operating system will put your

Re: Socket server + thread: cpu usage

2014-05-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 1 May 2014 at 08:08:37 UTC, Tim wrote: ... the CPU usage goes up. I think that SocketShutdown.BOTH causes Socket.select to fail which results in an endless loop. Any suggestions how to handle that problem? It shouldn't be here, disconnect would affect the new socket, and you're

Re: Socket server + thread: cpu usage

2014-04-30 Thread Damian Day via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 17:44:21 UTC, Tim wrote: On Tuesday, 29 April 2014 at 17:35:08 UTC, Tim wrote: On Tuesday, 29 April 2014 at 17:19:41 UTC, Adam D. Ruppe wrote: On Tuesday, 29 April 2014 at 17:16:33 UTC, Tim wrote: Is there anything I'm doing wrong? You should be using a blocking

Re: Socket server + thread: cpu usage

2014-04-30 Thread Ali Çehreli via Digitalmars-d-learn
On 04/30/2014 04:24 PM, Damian Day wrote: Thread.sleep( dur!(msecs)( 20 ) ); Going off topic, the UFCS syntax makes that code much more readable. :) Thread.sleep(20.msecs); Ali

Socket server + thread: cpu usage

2014-04-29 Thread Tim via Digitalmars-d-learn
Hi guys, I've the following snipped: TcpSocket oSocket = new TcpSocket(AddressFamily.INET); oSocket.bind(new InternetAddress(127.0.0.1, 12345)); oSocket.blocking(false); oSocket.listen(0); while(true) { try { Socket oRequestSocket = oSocket.accept();

Re: Socket server + thread: cpu usage

2014-04-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 17:16:33 UTC, Tim wrote: Is there anything I'm doing wrong? You should be using a blocking socket. With them, the operating system will put your thread on hold until a new connection comes in. Without them, it will endlessly loop doing absolutely nothing except

Re: Socket server + thread: cpu usage

2014-04-29 Thread Tim via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 17:19:41 UTC, Adam D. Ruppe wrote: On Tuesday, 29 April 2014 at 17:16:33 UTC, Tim wrote: Is there anything I'm doing wrong? You should be using a blocking socket. With them, the operating system will put your thread on hold until a new connection comes in.

Re: Socket server + thread: cpu usage

2014-04-29 Thread Tim via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 17:35:08 UTC, Tim wrote: On Tuesday, 29 April 2014 at 17:19:41 UTC, Adam D. Ruppe wrote: On Tuesday, 29 April 2014 at 17:16:33 UTC, Tim wrote: Is there anything I'm doing wrong? You should be using a blocking socket. With them, the operating system will put your

Re: Socket server + thread: cpu usage

2014-04-29 Thread Justin Whear via Digitalmars-d-learn
On Tue, 29 Apr 2014 17:16:32 +, Tim wrote: Hi guys, I've the following snipped: TcpSocket oSocket = new TcpSocket(AddressFamily.INET); oSocket.bind(new InternetAddress(127.0.0.1, 12345)); oSocket.blocking(false); oSocket.listen(0); while(true) { try { Socket