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: A lot of people want to use D,but they only know MS SQL Server,what will help them to Learn D?

2014-05-01 Thread FrankLike via Digitalmars-d-learn
On Monday, 14 April 2014 at 17:13:56 UTC, FrankLike wrote: My advice - use ODBC, it is the fastest way you may connect to the SQL server, and you already have everything you need for that. :) Regards I have test the d\dmd2\windows\lib\odbc32.lib,the size is 4.5kb, I test it by

Re: A lot of people want to use D,but they only know MS SQL Server,what will help them to Learn D?

2014-05-01 Thread Regan Heath via Digitalmars-d-learn
On Thu, 01 May 2014 09:56:49 +0100, FrankLike 1150015...@qq.com wrote: On Monday, 14 April 2014 at 17:13:56 UTC, FrankLike wrote: My advice - use ODBC, it is the fastest way you may connect to the SQL server, and you already have everything you need for that. :) Regards I have test the

Strings concatenated at compile time?

2014-05-01 Thread Unwise via Digitalmars-d-learn
In the following example from the documentation, are strings concatenated at compile time? template foo(string s) { string bar() { return s ~ betty; } } void main() { writefln(%s, foo!(hello).bar()); // prints: hello betty }

Re: Strings concatenated at compile time?

2014-05-01 Thread anonymous via Digitalmars-d-learn
On Thursday, 1 May 2014 at 10:42:36 UTC, Unwise wrote: In the following example from the documentation, are strings concatenated at compile time? template foo(string s) { string bar() { return s ~ betty; } } void main() { writefln(%s, foo!(hello).bar()); // prints: hello betty } I

Reading ELF Files

2014-05-01 Thread Nordlöw
Have anybody put together some D code for reading out tables from ELF files? A range/slice based version would be nice.

Re: Reading ELF Files

2014-05-01 Thread Tolga Cakiroglu via Digitalmars-d-learn
On Thursday, 1 May 2014 at 11:38:50 UTC, Nordlöw wrote: Have anybody put together some D code for reading out tables from ELF files? A range/slice based version would be nice. I don't know this though, in the morning Ubuntu has showed updates. One of them was libelf which says in its

Re: Strings concatenated at compile time?

2014-05-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Thu, 01 May 2014 11:12:41 + anonymous via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 1 May 2014 at 10:42:36 UTC, Unwise wrote: In the following example from the documentation, are strings concatenated at compile time? template foo(string s) {

Re: Strings concatenated at compile time?

2014-05-01 Thread bearophile via Digitalmars-d-learn
Jonathan M Davis: If you want it to be guaranteed, you'd do something like template foo(string s) { enum foo = s ~ betty; } A more general solution is to wrap the concatenation with a call to: alias ctEval(alias expr) = expr; Use: string bar() { return ctEval!(s ~ betty); } Bye,

Re: Reading ELF Files

2014-05-01 Thread yazd via Digitalmars-d-learn
On Thursday, 1 May 2014 at 11:38:50 UTC, Nordlöw wrote: Have anybody put together some D code for reading out tables from ELF files? A range/slice based version would be nice. I have some simple proof of concept code. It is currently able to read elf64 (can be easily adjusted to read elf32

Re: Reading ELF Files

2014-05-01 Thread Nordlöw
I have some simple proof of concept code. It is currently able to read elf64 (can be easily adjusted to read elf32 too) headers, extract sections and read string tables. If this is what you need, then I'll upload my code somewhere (although again, it is quite simplistic). If you specify what

Re: Reading ELF Files

2014-05-01 Thread Nordlöw
again, it is quite simplistic). If you specify what you need a bit more, I might be able to provide that. Please, post :)

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: Reading ELF Files

2014-05-01 Thread yazd via Digitalmars-d-learn
On Thursday, 1 May 2014 at 13:10:33 UTC, Nordlöw wrote: again, it is quite simplistic). If you specify what you need a bit more, I might be able to provide that. Please, post :) Here you go, https://github.com/yazd/elf-d.

Re: Reading ELF Files

2014-05-01 Thread Nordlöw
Here you go, https://github.com/yazd/elf-d. Thanks!

Unresolved external symbol

2014-05-01 Thread Ga via Digitalmars-d-learn
I have the following code: import std.stdio; version(Windows) { extern(Windows) { nothrow { alias void *HANDLE; alias HANDLE HDC; int GetDeviceCaps(HDC, int);

Making enum join variadic

2014-05-01 Thread Nordlöw
How can I make `join` variadic (by filling in njoin) in the following code? import std.stdio: writeln; import std.traits; string enumsHelper(S...)(S s) { typeof(return) r; foreach (i, e; s) { if (i = 1) r ~= , ; r ~= e; } return r; } /**

Re: Making enum join variadic

2014-05-01 Thread bearophile via Digitalmars-d-learn
Nordlöw: How can I make `join` variadic (by filling in njoin) in the following code? When you have a D tuple (not Phobos tuple), and it contains values all of the same type, you can turn it into an array with just: [mytuple] Once you have an array of strings, you can use the normal

Re: Making enum join variadic

2014-05-01 Thread Artur Skawina via Digitalmars-d-learn
On 05/02/14 00:24, Nordlöw via Digitalmars-d-learn wrote: How can I make `join` variadic (by filling in njoin) in the following code? import std.array, std.range, std.algorithm; import std.stdio; template Njoin(ES...) { mixin({ string r = enum Njoin { ; foreach