I agree that the Read method is not quite that remoting friendly. ;) Anyway, the 
there's not much work to do here, to get read of the extra traffic: just provide a 
server side method that has a signature similair to:

public static int Read(out byte[] buffer, int offset, int count);

I assume this creates a byte array at the server and passes it to the client -- 
doesn't it? (I'm not really into parameter modifiers, so please correct me if I'm 
wrong...)

-- Stefan
  ----- Original Message ----- 
  From: Axel Heitland 
  To: Moderated discussion of advanced .NET topics. 
  Sent: Thursday, August 15, 2002 6:24 PM
  Subject: RE: [ADVANCED-DOTNET] Why has a MarshallByRefObject Stream.Read(..) byte[] 
as IN Parameter


  Hmm...

  What he has is a Stream at the server....

  So a read should surely transfer back the results to the client (the
  [out] direction).

  The error is that the client unnecessarily uploads the bytes to the
  server.
  This behaviour is time- and bandwidth consuming.

  Since Stream extends MarshalByRefObject it looks like the Stream methods
  are not optimal modelled for remoting...

  If true that is a little bit more than just a documentation error ;-))

  My regards
          Axel

  -----Original Message-----
  From: Stefan Holdermans [mailto:[EMAIL PROTECTED]]
  Sent: Donnerstag, 15. August 2002 14:52
  To: [EMAIL PROTECTED]
  Subject: Re: [ADVANCED-DOTNET] Why has a MarshallByRefObject
  Stream.Read(..) byte[] as IN Parameter


  Dirk,

  Actually, the correct CIL signature for Stream.Read is:

  .method public hidebysig newslot virtual abstract 
          instance int32 Read([in][out] unsigned int8[] buffer,
                              int32 offset,
                              int32 count) cil managed
  {
  }

  The corresponding C# syntax for this is :

  public abstract int Read(ref byte[] buffer, int offset, int count);

  in is not a valid parameter modifier in C#; so, I guess, this qualifies
  as a documentation error.

  Anyway, the out modifier causes the buffer to be transferred back. To
  avoid this, you can provide a wrapper for the Read method on your server
  component.

  HTH,

  Stefan
    ----- Original Message ----- 
    From: Dirk Reuss 
    To: [EMAIL PROTECTED] 
    Sent: Wednesday, August 14, 2002 1:05 PM
    Subject: Why has a MarshallByRefObject Stream.Read(..) byte[] as IN
  Parameter


    Hello,
    I implemented a Stream for transfering data over the network.
    On the remote (client) side I have a proxy to a stream object.

    Client Code:
    Stream stream = remoteserverobject.GetStream();
    byte [] buffer = new byte[1024*1024];
    stream.Read(buffer,0,1024*1024) ;

    The buffer is transferd (1MB) from the client to the server and if the
  Read
    call returns the buffer is transfered back (OK). So the network volumn
  is
    2MB.IMO that's 1MB to much.

    The signature for Read is:

    [C#]
    [Serializable]
    public abstract int Read(
       in byte[] buffer,
       int offset,
       int count
    );

    The buffer parameter is explicitly marked as in. I couldn't understand
  why.
    I think this happens not only for my channel.
    Is there any workaround with remoting attributes?
    Interop Marshalling Attributes don't work.
    The transport is Tcpip with TcpIpChannel.

    I tried:
    byte [] buffer = new byte[0];
    stream.Read(buffer,0,1024*1024) ;

    Stream::Read(byte[] buffer...)
    {

    }


    Regards,
    Dirk

    You can read messages from the Advanced DOTNET archive, unsubscribe
  from Advanced DOTNET, or
    subscribe to other DevelopMentor lists at http://discuss.develop.com.


  You can read messages from the Advanced DOTNET archive, unsubscribe from
  Advanced DOTNET, or
  subscribe to other DevelopMentor lists at http://discuss.develop.com.

  You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
  subscribe to other DevelopMentor lists at http://discuss.develop.com.


You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to