> hello willy..
>
[quoted text clipped - 54 lines]
>>
>> Willy.
hello willy..
thank you for your reply.
(A) C++ <-- COM --> (B) C# <--- .NET remoting ---> (C) C#
= > yes, i want to make my program like above.
= > i want to exchange data from win32, and C++.
How did you measure?
=> i wrote a time in cosole at remote server after Server received data from
client.
What (results) did you measure?
=>time...
What did you expect?
What are you requirements?
What data types are you passing?
=> i made a structure like below
=> typedef structure strValue
{
int Count;
char *chName;
char *chAddress;
char *price;
enum enKind;
}
=> i want to send the struture 10000 Numbers for 100ms from client to server
> COM interop:
> Is this an in-proc , or out-proc server scenario?
=> before i made out-of-process with singleton by atl.
=> but today i have made new one with in-process using C#.
> ..NET remoting:
> What's the "distance" between B and C (same machine , local network,
> WAN, ...)?
=> different machine and local network.
What's the protocol used?
=> tcp/ip
What kind of formatter do you use?
=> binary.
can i ask you soemthing?
i have made in-process using C# today.
i passed variant between c++ and C#.
so i have to prepare variant type in c++.
can i pass structure from c++ to C#.
because if i can send structure from c++ to C#.
that is better than send variant from c++ to C#
thank you very much ...
> From what I understand, you have the following scenario:
>
[quoted text clipped - 81 lines]
> >>
> >> Willy.
Willy Denoyette [MVP] - 31 Mar 2008 23:48 GMT
Well, from what I understood, I can say that you don't need to make it that
complicated and slow.
The first option is to get rid of the .NET remoting part, and use DCOM as
protocol, to do this you have to:
- Derive a class from System.EnterpriseServices.ServicedComponent and
register the class (using regsvcs.exe) to run as a COM+ server type
application (out-proc).
- Export a proxy, for this application, using COM+ admin (run dcomcnfg.exe).
- Install the proxy (an MSI file) on the client machine(s).
- COM clients and .NET clients can now call the COM+ server application on
the remote server.
In order to reduce the marshaling overhead you'll have to specify your data
structure at the server (C#) like this:
[Guid("your own private guid here")]
[ComVisible(true)]
public struct strValue
{
public int count;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public string chName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public string chAddress;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string price;
public int enKind;
}
Adapt the SizeConst values to suit your needs, note that I assume your char
fields have a fixed length.
The above declarations will export the structure in the tlb file with the
string fields declared as:
unsigned char chName[64];
..
};
At the server (C++) you need to:
- import the typelib created when running regsvcs.exe above using VC++
"import" directive.
#import "your_server.tlb" no_namespace
- To get at the record description (the above structure) you'll have to
call GetRecordInfoFromGuids , and pass the recordInfo in the call to
SafeArrayCreateEx, something like this....
strValue *pstrValue = NULL;
IRecordInfo *precordInfo = NULL;
HRESULT hr = GetRecordInfoFromGuids( __uuidof(__SomeClass),
1, 0, 0, __uuidof(strValue),
&pLoadRecordInfo );
// set the array bounds...
// and create the sa
LPSAFEARRAY psastrValue = SafeArrayCreateEx(VT_RECORD, 1, rgsabound,
precordInfo );
..
hr = SafeArrayAccessData(psastrValue ,
reinterpret_cast<PVOID*>(&pstrValue ));
// fill the array with data.. using
// and detach when done
SafeArrayUnaccessData(...)
call the server passing the array as argument.
Note that your requirements of 10000 structures per second cannot be
guraranteed, you'll have to measure, but with a structure size 200 bytes and
a fast reliable and not congested network (>= 100Mbps), it should be
possible to pass 10000 * 200 byte structures over DCOM .
The second option is to get rid of both COM and .NET remoting, and go for a
socket based client/server solution, this is the fastest solution, but you
loose quite a bit offered by the COM+ infrastructure, you need to write more
code, and you need to marshal the structure yourself, but as the structure
is quite simple, this shouldn't be an big issue.
Willy.
> hello willy..
>
[quoted text clipped - 141 lines]
>> >>
>> >> Willy.