Home Help Center

How to transfer data between server/client

g00fyg00fy Member SalvaniaOrganization: SalvaniaProject: Database systems ✭✭
Hi,


How is it possible to transfer data between a server and a client? And then more detailed between a C++ server and a PHP client?

At the C++ side I have an interface called Blob:
sequence<byte>  ByteSeq;
  const int       maximumSizeOfBlob = 64000;
  enum SeekMode
  {
    fromStart,
    fromEnd,
    fromCurrent
  };

  interface Blob
  {
    idempotent bool seek( long offset, SeekMode mode );
    nonmutating long tell( );
    ByteSeq fetch( );
    nonmutating bool eof( );
    nonmutating long size( );
  };

Basically it interfaces fseek(), ftell(), feof() functions of the C-library (but it could be extended to have an istream at the back, or a databasepointer or whatever).

So I just return a BlobPrx to whatever client is wanting to read data...

And that's where my problem is...
If I want to write data from PHP -> C++, I thought I could do something like "class Blob implements NS_Blob" and implement those functions, get a "new Blob($path)" and send this to the C++ side...
Seems i couldn't have been more wrong. It keeps complaining about "Class Blob contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Ice_Object::ice_preMarshal, Ice_Object::ice_postUnmarshal)".
I guess that's the technical implementation of the ICE-protocol, so I am absolutely not touching those :), nor will I be implementing them in my PHP class ;).

The question of this thread is thus how I can transfer (binary) data from my PHP client -> C++ backend... Ofcourse I can just put it in a string in PHP and send it over, but what if I want to send a file of like 1G? That would surely crash both client and server (if it would receive this string at all).

I also took a quick look at icePatch2, but that's also a no-go I guess as it's a server->client 'feature'. Furthermore I took a look at the documentation again and saw the FileSystem exemple, but that's a no-go as well because it will return a sequence<string>, which... In the case of binary files is first of all difficult to return a string, and second if the file is like 1G, it's also going to crash again...

So what could I possibly do to make this work?

Thanks,

Comments

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi g00fy

    i make samething similar to what are trying to do, i resolve the problem spliting the write in smallest write operations.
    interface fileService
    {
        FileWriter* getFileWriter(string path);
    }
    interface fileWriter
    {
          void appendChunk(long pos,ByteSeq content);
    }
    

    in the client you split the file to Write a ByteSeq of a given size and call appendChunk in a fileWriter
  • g00fyg00fy Member SalvaniaOrganization: SalvaniaProject: Database systems ✭✭
    Hi xdm,


    Thanks for your reply... I was thinking of something like that...

    What you do is get a FileWriter from somewhere on the server side, passing it a path (I would - for my application - drop that as I don't know anything about where my data is going to - from a client perspective). Then you just split up the data in the client (php) and send it to the server?

    How do you manage to tell if you're at the end of the file?
    How did you capture the possibility of the file being written while the connection is dropped? [I think this is handled well by the ICE framework]


    Thanks,
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
  • g00fyg00fy Member SalvaniaOrganization: SalvaniaProject: Database systems ✭✭
    :o I will look at the FAQ next time :o
  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    i don't manage end of file as especial case, you can allways add a new ByteSeq to a given pos. you can use a especial flag that the clients set for this.


    if connection is lost when write you reive and exception and can retry the operation while you consider oportune, note that if you define write as idempotent Ice can retry it tranparently
Sign In or Register to comment.