Jump to page: 1 2
Thread overview
how to read some in vibe.d tcpconnection?
Mar 06, 2015
zhmt
Mar 06, 2015
zhmt
Mar 06, 2015
Rikki Cattermole
Mar 06, 2015
zhmt
Mar 06, 2015
Stefan Koch
Mar 06, 2015
zhmt
Mar 06, 2015
Stefan Koch
Mar 06, 2015
Kagamin
Mar 06, 2015
zhmt
Mar 06, 2015
zhmt
Mar 07, 2015
zhmt
Mar 07, 2015
Kagamin
Mar 08, 2015
zhmt
Mar 08, 2015
Kagamin
Mar 09, 2015
zhmt
Mar 07, 2015
ketmar
March 06, 2015
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 ?
March 06, 2015
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 method works in this scene.

I have read the document of TCPConnection, found nothing helpful.

Will somebody help me?
March 06, 2015
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 dont think the TCPConnecion.read method works in this scene.
>
> I have read the document of TCPConnection, found nothing helpful.
>
> Will somebody help me?

Take a look at empty and leastSize.

https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/stream.d#L33
March 06, 2015
>
> 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 :

 basic_stream_socket::read_some (1 of 2 overloads)

 This function is used to read data from the stream socket. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.
March 06, 2015
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 boost::asio, It has a method like this :
>
>  basic_stream_socket::read_some (1 of 2 overloads)
>
>  This function is used to read data from the stream socket. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.

There should be a function called DataAvilable.
Simply read the data if this function returns true
March 06, 2015
> 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?

March 06, 2015
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.
>
> Is there more info to solve this problem?

you first check dataAvilableForRead
and then leastSize
March 06, 2015
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.
March 06, 2015
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.
March 06, 2015
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 to use in real work.

You might want to go lower level:

http://stackoverflow.com/questions/17590816/kernel-based-linux-data-relay-between-two-tcp-sockets
« First   ‹ Prev
1 2