C
cody
Would be great if you could provide the code how you are receiving the
packets in C# so we can see how to help you.
packets in C# so we can see how to help you.
cody said:Would be great if you could provide the code how you are receiving the
packets in C# so we can see how to help you.
--
cody
Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Tamir Khason said:Follwing the struct:
[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi)]
public struct TpSomeMsgRep
{
public uint SomeId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public Byte[] notinuse1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=674)]
public Byte[] theMainPart;
}
This used to cast from buffer, recieved by TCP from C++ Program, like this:
oMsgRes= (mm.TpSomeMsgRep )SomeBuffer;
This work fine with Unix server. once transfer to Windows I can not cast to
the structure.
PLEASE HELP HELP HELP!
Tamir Khason said:Follwing the struct:
[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi)]
public struct TpSomeMsgRep
{
public uint SomeId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public Byte[] notinuse1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=674)]
public Byte[] theMainPart;
}
This used to cast from buffer, recieved by TCP from C++ Program, like this:
oMsgRes= (mm.TpSomeMsgRep )SomeBuffer;
This work fine with Unix server. once transfer to Windows I can not cast to
the structure.
BMermuys said:Hi,
Tamir Khason said:Follwing the struct:
[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi)]
public struct TpSomeMsgRep
{
public uint SomeId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public Byte[] notinuse1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=674)]
public Byte[] theMainPart;
}
This used to cast from buffer, recieved by TCP from C++ Program, like this:
oMsgRes= (mm.TpSomeMsgRep )SomeBuffer;
This work fine with Unix server. once transfer to Windows I can not cast to
the structure.
What and how are you casting, if you want to cast a byte array to your
struct, you must use marshalling functionality:
byte [] buf = * received * ;
GCHandle h = GCHandle.Alloc( buf, GCHandleType.Pinned );
TpSomeMsgRep rep = (TpSomeMsgRep)Marshal.PtrToStruct(h.AddrOfPinnedObject(),
typeof(TpSomeMsgRep));
h.Free();
// use rep
If you need something else, be more specific.
HTH,
greetings
PLEASE HELP HELP HELP!
Tamir Khason said:I'm doing this.
The question is what can be different between the packets between Unix and
Windows packets...
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
BMermuys said:Hi,
castTamir Khason said:Follwing the struct:
[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi)]
public struct TpSomeMsgRep
{
public uint SomeId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public Byte[] notinuse1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=674)]
public Byte[] theMainPart;
}
This used to cast from buffer, recieved by TCP from C++ Program, like this:
oMsgRes= (mm.TpSomeMsgRep )SomeBuffer;
This work fine with Unix server. once transfer to Windows I can not
tothe structure.
What and how are you casting, if you want to cast a byte array to your
struct, you must use marshalling functionality:
byte [] buf = * received * ;
GCHandle h = GCHandle.Alloc( buf, GCHandleType.Pinned );
TpSomeMsgRep rep = (TpSomeMsgRep)Marshal.PtrToStruct(h.AddrOfPinnedObject(),
typeof(TpSomeMsgRep));
h.Free();
// use rep
If you need something else, be more specific.
HTH,
greetings
PLEASE HELP HELP HELP!
Yes, both servers sources were compiled with alignment 4 both for unix (sun)may cause different struct layout's but that is compiler dependent not
platform.
No, PtrToStruct works well, but in cast withWhat's exactly is the problem you have ? Does PtrToStruct throw ?
Unexpected data ??
BMermuys said:Tamir Khason said:I'm doing this.
The question is what can be different between the packets between Unix and
Windows packets...
You're are still not very clear. Is this server written in c++ compiled for
both linux/windows?
I don't think struct differ from one platform to another. Struct alignment
may cause different struct layout's but that is compiler dependent not
platform.
What's exactly is the problem you have ? Does PtrToStruct throw ?
Unexpected data ??
greetings
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
BMermuys said:Hi,
Follwing the struct:
[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi)]
public struct TpSomeMsgRep
{
public uint SomeId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public Byte[] notinuse1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=674)]
public Byte[] theMainPart;
}
This used to cast from buffer, recieved by TCP from C++ Program, like
this:
oMsgRes= (mm.TpSomeMsgRep )SomeBuffer;
This work fine with Unix server. once transfer to Windows I can not cast
to
the structure.
What and how are you casting, if you want to cast a byte array to your
struct, you must use marshalling functionality:
byte [] buf = * received * ;
GCHandle h = GCHandle.Alloc( buf, GCHandleType.Pinned );
TpSomeMsgRep rep = (TpSomeMsgRep)Marshal.PtrToStruct(h.AddrOfPinnedObject(),
typeof(TpSomeMsgRep));
h.Free();
// use rep
If you need something else, be more specific.
HTH,
greetings
PLEASE HELP HELP HELP!
Tamir Khason said:Struct alignmentYes, both servers sources were compiled with alignment 4 both for unix (sun)may cause different struct layout's but that is compiler dependent not
platform.
and windows
No, PtrToStruct works well, but in cast withWhat's exactly is the problem you have ? Does PtrToStruct throw ?
Unexpected data ??
(MyStruct)ObjectSerializedFromBinaryStream failed.
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
BMermuys said:Tamir Khason said:I'm doing this.
The question is what can be different between the packets between Unix and
Windows packets...
You're are still not very clear. Is this server written in c++ compiled for
both linux/windows?
I don't think struct differ from one platform to another. Struct alignment
may cause different struct layout's but that is compiler dependent not
platform.
What's exactly is the problem you have ? Does PtrToStruct throw ?
Unexpected data ??
greetings
not--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
Hi,
Follwing the struct:
[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi)]
public struct TpSomeMsgRep
{
public uint SomeId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public Byte[] notinuse1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=674)]
public Byte[] theMainPart;
}
This used to cast from buffer, recieved by TCP from C++ Program, like
this:
oMsgRes= (mm.TpSomeMsgRep )SomeBuffer;
This work fine with Unix server. once transfer to Windows I can
castto
the structure.
What and how are you casting, if you want to cast a byte array to your
struct, you must use marshalling functionality:
byte [] buf = * received * ;
GCHandle h = GCHandle.Alloc( buf, GCHandleType.Pinned );
TpSomeMsgRep rep =
(TpSomeMsgRep)Marshal.PtrToStruct(h.AddrOfPinnedObject(),
typeof(TpSomeMsgRep));
h.Free();
// use rep
If you need something else, be more specific.
HTH,
greetings
PLEASE HELP HELP HELP!
cody said:What is ObjectSerializedFromBinaryStream? It seems not to be part of the
Framework.
If you want that we help you you have to provive more information for
example show your code that receives the packets.
--
cody
Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Tamir Khason said:Struct alignmentYes, both servers sources were compiled with alignment 4 both for unix (sun)may cause different struct layout's but that is compiler dependent not
platform.
and windows
No, PtrToStruct works well, but in cast withWhat's exactly is the problem you have ? Does PtrToStruct throw ?
Unexpected data ??
(MyStruct)ObjectSerializedFromBinaryStream failed.
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
UnixBMermuys said:I'm doing this.
The question is what can be different between the packets between
andcompiledWindows packets...
You're are still not very clear. Is this server written in c++
forboth linux/windows?
I don't think struct differ from one platform to another. Struct alignment
may cause different struct layout's but that is compiler dependent not
platform.
What's exactly is the problem you have ? Does PtrToStruct throw ?
Unexpected data ??
greetings
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
Hi,
Follwing the struct:
[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi)]
public struct TpSomeMsgRep
{
public uint SomeId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public Byte[] notinuse1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=674)]
public Byte[] theMainPart;
}
This used to cast from buffer, recieved by TCP from C++ Program, like
this:
oMsgRes= (mm.TpSomeMsgRep )SomeBuffer;
This work fine with Unix server. once transfer to Windows I can not
cast
to
the structure.
What and how are you casting, if you want to cast a byte array to your
struct, you must use marshalling functionality:
byte [] buf = * received * ;
GCHandle h = GCHandle.Alloc( buf, GCHandleType.Pinned );
TpSomeMsgRep rep =
(TpSomeMsgRep)Marshal.PtrToStruct(h.AddrOfPinnedObject(),
typeof(TpSomeMsgRep));
h.Free();
// use rep
If you need something else, be more specific.
HTH,
greetings
PLEASE HELP HELP HELP!
relations etc.
The point is that there are diferences between unix and windows TCP or
binary stream....
Tamir Khason said:Struct alignment
Yes, both servers sources were compiled with alignment 4 both for unix (sun)
and windows
No, PtrToStruct works well, but in cast withWhat's exactly is the problem you have ? Does PtrToStruct throw ?
Unexpected data ??
(MyStruct)ObjectSerializedFromBinaryStream failed.
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
BMermuys said:Tamir Khason said:I'm doing this.
The question is what can be different between the packets between Unix and
Windows packets...
You're are still not very clear. Is this server written in c++ compiled for
both linux/windows?
I don't think struct differ from one platform to another. Struct alignment
may cause different struct layout's but that is compiler dependent not
platform.
What's exactly is the problem you have ? Does PtrToStruct throw ?
Unexpected data ??
greetings
not--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
Hi,
Follwing the struct:
[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi)]
public struct TpSomeMsgRep
{
public uint SomeId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public Byte[] notinuse1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=674)]
public Byte[] theMainPart;
}
This used to cast from buffer, recieved by TCP from C++ Program, like
this:
oMsgRes= (mm.TpSomeMsgRep )SomeBuffer;
This work fine with Unix server. once transfer to Windows I can
castto
the structure.
What and how are you casting, if you want to cast a byte array to your
struct, you must use marshalling functionality:
byte [] buf = * received * ;
GCHandle h = GCHandle.Alloc( buf, GCHandleType.Pinned );
TpSomeMsgRep rep =
(TpSomeMsgRep)Marshal.PtrToStruct(h.AddrOfPinnedObject(),
typeof(TpSomeMsgRep));
h.Free();
// use rep
If you need something else, be more specific.
HTH,
greetings
PLEASE HELP HELP HELP!
Tamir Khason said:The problem is WHAT I'M passing in.
I revieve the stream from C++ server.
When it was in UNIX enviroment - everything worked ok, but once they
treanfer to Windows the problem begun. There are same structures, but as far
as I understand , not the same stream - thet's the single explanation I can
think about...
BMermuys said:Hi,
Tamir Khason said:Struct alignment
Yes, both servers sources were compiled with alignment 4 both for unix (sun)
and windows
Then why are you using Pack=1 on the struct ?
Greetings
No, PtrToStruct works well, but in cast withWhat's exactly is the problem you have ? Does PtrToStruct throw ?
Unexpected data ??
(MyStruct)ObjectSerializedFromBinaryStream failed.
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
UnixBMermuys said:I'm doing this.
The question is what can be different between the packets between
andcompiledWindows packets...
You're are still not very clear. Is this server written in c++
forboth linux/windows?
I don't think struct differ from one platform to another. Struct alignment
may cause different struct layout's but that is compiler dependent not
platform.
What's exactly is the problem you have ? Does PtrToStruct throw ?
Unexpected data ??
greetings
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
Hi,
Follwing the struct:
[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi)]
public struct TpSomeMsgRep
{
public uint SomeId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public Byte[] notinuse1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=674)]
public Byte[] theMainPart;
}
This used to cast from buffer, recieved by TCP from C++ Program, like
this:
oMsgRes= (mm.TpSomeMsgRep )SomeBuffer;
This work fine with Unix server. once transfer to Windows I can not
cast
to
the structure.
What and how are you casting, if you want to cast a byte array to your
struct, you must use marshalling functionality:
byte [] buf = * received * ;
GCHandle h = GCHandle.Alloc( buf, GCHandleType.Pinned );
TpSomeMsgRep rep =
(TpSomeMsgRep)Marshal.PtrToStruct(h.AddrOfPinnedObject(),
typeof(TpSomeMsgRep));
h.Free();
// use rep
If you need something else, be more specific.
HTH,
greetings
PLEASE HELP HELP HELP!
structTamir Khason said:Thank you for response.
1) The source server was Sun (not Linux)
2) no, the client is C# and I'm cast Object (created from Byte[]) to
BMermuys said:Hi,
structTamir Khason said:Thank you for response.
1) The source server was Sun (not Linux)
2) no, the client is C# and I'm cast Object (created from Byte[]) to
Yes, but how is the server (c++) sending this struct ?
Server-side there should be a struct to byte conversion, how is it done ?
Simple casting or is each field send seperatly ?
Greetings
but3) No problem, it works with Sun server, but I think does not with Windows
serverexplanationI classes
with TCP
the type I recieved is Object