passing filehandles among classes

This is a discussion on passing filehandles among classes within the C++ Programming forums, part of the General Programming Boards category; I'm trying to open a file in the client and pass the filehandle to the server (where the file is ...

passing filehandles among classes

I'm trying to open a file in the client and pass the filehandle to the server (where the file is read).
I'm having problems using the filehandle in the server as it is invalid in the server.
Does anyone know how I could solve this prob or if I'm doing anything wrong?

here is what I have ...
IN CLIENT ...
int filehandle;
filehandle = _open(filename, _O_RDONLY);
x(filehandle); // x is some function in the server
_close(filehandle);

well, I have a COM dll (in-process server) and a client calling the dll functions.

I open the file in the client and pass the file handle (of type int) to the dll where the file is read. Still can't figure out why it is invalid in the dll (since the dll runs in the same process as its client).