Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
Hi,I got the right answer in vibe.d forum,here is the link: http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/24403/#post-24416

Re: Int to float?

2015-03-06 Thread bearophile via Digitalmars-d-learn
Ola Fosheim Grøstad: D claims to follow C, so using unions for type punning is ultimately implementation defined. I am not sure if D is the same as C regarding this. Bye, bearophile

Initializing defaults based on type.

2015-03-06 Thread anon via Digitalmars-d-learn
Hi, I can't figure this out. struct Pair(T) { T x; T y; alias x c; alias y r; } What would like is that the x and y to be initialized to different values depending on type eg: struct Container { Pair!double sample1; // This will initialize sample1 with 0 for both x and y

Re: how to write a string to a c pointer?

2015-03-06 Thread FG via Digitalmars-d-learn
On 2015-03-06 at 00:25, ketmar wrote: unicode sux[1]. [1] http://file.bestmx.net/ee/articles/uni_vs_code.pdf Great article. Thanks, Кетмар ⚠ ∑ ♫ ⚽ ☀ ☕ ☺ ≡ ♛

how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
TCPConnecion has a read method, which will block untill the buf is fully filled. This is not what I want. I want a readSome method, which will return if some data comes from remote end, and notify the length of data to me. so I can process data in time. what should I do ?

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
There should be a function called DataAvilable. Simply read the data if this function returns true Thanks you! But the DataAvilable just return a bool value, so I dont know the available data size, I cant call the read method simply. Is there more info to solve this problem?

Re: Int to float?

2015-03-06 Thread Nicolas Sicard via Digitalmars-d-learn
On Friday, 6 March 2015 at 00:57:16 UTC, Ola Fosheim Grøstad wrote: On Thursday, 5 March 2015 at 23:50:28 UTC, Jesse Phillips wrote: I think I read somewhere you don't want to use unions like this, but I think it is more because you generally don't want to reinterpret bits. It is

Re: Initializing defaults based on type.

2015-03-06 Thread Benjamin Thaut via Digitalmars-d-learn
On Friday, 6 March 2015 at 15:36:47 UTC, anon wrote: Hi, I can't figure this out. struct Pair(T) { T x; T y; alias x c; alias y r; } What would like is that the x and y to be initialized to different values depending on type eg: struct Container { Pair!double sample1; //

Re: Initializing defaults based on type.

2015-03-06 Thread Ali Çehreli via Digitalmars-d-learn
On 03/06/2015 08:04 AM, Benjamin Thaut wrote: On Friday, 6 March 2015 at 15:36:47 UTC, anon wrote: Hi, I can't figure this out. struct Pair(T) { T x; T y; alias x c; alias y r; } What would like is that the x and y to be initialized to different values depending on type eg:

Re: Initializing defaults based on type.

2015-03-06 Thread ketmar via Digitalmars-d-learn
On Fri, 06 Mar 2015 08:39:55 -0800, Ali Çehreli wrote: And an overengineered solution: :p this is definitely the best. signature.asc Description: PGP signature

Re: I want to introduce boost_asio to dlang

2015-03-06 Thread ketmar via Digitalmars-d-learn
On Fri, 06 Mar 2015 03:12:44 +, Messenger wrote: On Thursday, 5 March 2015 at 07:38:35 UTC, ketmar wrote: On Thu, 05 Mar 2015 06:05:55 +, zhmt wrote: But I am not familiar with dlang this is the root of the problem. please, make yourself familiar before starting to wrap boost crap.

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 6 March 2015 at 10:16:32 UTC, zhmt wrote: There should be a function called DataAvilable. Simply read the data if this function returns true Thanks you! But the DataAvilable just return a bool value, so I dont know the available data size, I cant call the read method simply.

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread Rikki Cattermole via Digitalmars-d-learn
On 6/03/2015 10:30 p.m., zhmt wrote: I am forwarding data from client to another server, if the client send data to server,I want to forward that to another server in time. So, if the server recieves nothing it will wait, if it receive some data , forward them to another server immediately. I

Re: I want to introduce boost_asio to dlang

2015-03-06 Thread zhmt via Digitalmars-d-learn
On Friday, 6 March 2015 at 09:30:51 UTC, ketmar wrote: On Fri, 06 Mar 2015 01:19:40 +, zhmt wrote: Thanks for all the suggestions and pointing the right direction,I will learn and try vibe.d, try to use it in my gameserver. i've seen people using vibe.d to write warcraft server, so it's

Re: I want to introduce boost_asio to dlang

2015-03-06 Thread ketmar via Digitalmars-d-learn
On Fri, 06 Mar 2015 01:19:40 +, zhmt wrote: Thanks for all the suggestions and pointing the right direction,I will learn and try vibe.d, try to use it in my gameserver. i've seen people using vibe.d to write warcraft server, so it's definitely is working. you can find that on github, i

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
I am forwarding data from client to another server, if the client send data to server,I want to forward that to another server in time. So, if the server recieves nothing it will wait, if it receive some data , forward them to another server immediately. I dont think the TCPConnecion.read

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
Take a look at empty and leastSize. https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/stream.d#L33 @Rikki Cattermole Thanks for your reply, but it is not what I want, and I cant implement my goal with them. in boost::asio, It has a method like this :

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 6 March 2015 at 10:10:35 UTC, zhmt wrote: Take a look at empty and leastSize. https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/stream.d#L33 @Rikki Cattermole Thanks for your reply, but it is not what I want, and I cant implement my goal with them. in

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread Kagamin via Digitalmars-d-learn
I'd say, peek is the right method, it returns what's already in the buffer (but doesn't read), while leastSize returns full logical size of the stream.

Re: Initializing defaults based on type.

2015-03-06 Thread Kagamin via Digitalmars-d-learn
On Friday, 6 March 2015 at 16:39:56 UTC, Ali Çehreli wrote: mixin (makePairInitValueDefinitions()); Oh, so that's how you do static foreach.

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread via Digitalmars-d-learn
On Friday, 6 March 2015 at 19:33:56 UTC, zhmt wrote: On Friday, 6 March 2015 at 18:40:28 UTC, Kagamin wrote: I'd say, peek is the right method, it returns what's already in the buffer (but doesn't read), while leastSize returns full logical size of the stream. The api of vibe.d is too simple

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
On Friday, 6 March 2015 at 20:03:52 UTC, Ola Fosheim Grøstad wrote: On Friday, 6 March 2015 at 19:33:56 UTC, zhmt wrote: On Friday, 6 March 2015 at 18:40:28 UTC, Kagamin wrote: I'd say, peek is the right method, it returns what's already in the buffer (but doesn't read), while leastSize

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
On Friday, 6 March 2015 at 18:40:28 UTC, Kagamin wrote: I'd say, peek is the right method, it returns what's already in the buffer (but doesn't read), while leastSize returns full logical size of the stream. The api of vibe.d is too simple to use in real work.

Re: Initializing defaults based on type.

2015-03-06 Thread Artur Skawina via Digitalmars-d-learn
On 03/06/15 22:29, Artur Skawina wrote: No, you implement it using CTFE magic, and then that code becomes: #foreach (N; 0..PairInitValues.length/2) { enum PairInitValue(T:PairInitValues[$N*2]) = PairInitValues[$N*2+1]; } Seriously though, avoid using `.stringof` when generating

Re: Initializing defaults based on type.

2015-03-06 Thread Artur Skawina via Digitalmars-d-learn
On 03/06/15 19:27, Kagamin via Digitalmars-d-learn wrote: On Friday, 6 March 2015 at 16:39:56 UTC, Ali Çehreli wrote: mixin (makePairInitValueDefinitions()); Oh, so that's how you do static foreach. No, you implement it using CTFE magic, and then that code becomes: import std.typetuple;

Re: Cycle detected between modules with ctors/dtors

2015-03-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/4/15 4:15 PM, rumbu wrote: On Wednesday, 4 March 2015 at 16:08:00 UTC, Steven Schveighoffer wrote: curiously not listed? That doesn't make any sense. If there is not a cycle in the listed modules, where at least 2 modules have a static ctor or static dtor, then there is a bug in the

Re: how to write a string to a c pointer?

2015-03-06 Thread Kagamin via Digitalmars-d-learn
On Friday, 6 March 2015 at 00:53:49 UTC, Ali Çehreli wrote: It made me happy that I was not the only person who has been ruminating over alphabet as the crucial piece in this whole Unicode story. I've been giving the example of if I have a company name as the string ali jim, the uppercase of