Author Topic: 32 and 64 bit...  (Read 10235 times)

Mainclain

  • Not-a-newbie
  • *
  • Posts: 14
  • Karma: 0
    • View Profile
32 and 64 bit...
« on: July 12, 2012, 02:21:16 PM »
Hello,

I use RakNet 4.04 with Swig and C#.
I have compiled it for Windows and for Linux - and it works fine on both.
But when run the server on x86_64 Linux i can only use RakNet in the x86_64 version.

Now I had the problem, that when I sent an Int I get on my client something like that:
Server:
stream.Write(123);
stream.Write(456);
Client:
stream.Read(out v1);
stream.Read(out v2);
stream.Read(out v3);
stream.Read(out v4);

v1 = 0
v2 = 123
v3 = 0
v4 = 123

(or the number first).
So how can I do that correctly? It seems like the 64bit Mono can't work with 32bit native DLLs.

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: 32 and 64 bit...
« Reply #1 on: July 12, 2012, 08:51:47 PM »
Just like anytime you read or write a number you have to specify its size. On C++ this would be uint64_t or uint32_t

Mainclain

  • Not-a-newbie
  • *
  • Posts: 14
  • Karma: 0
    • View Profile
Re: 32 and 64 bit...
« Reply #2 on: July 13, 2012, 03:41:08 AM »
I tried it with using Int32 but that's not working. So do I have the make my own functions to convert the datatypes into bytes and write them?

Okay I will just Edit my RakNetSwig.dll It seems to work when I dont use raknet functions.

Reading Ints:
Code: [Select]
   public bool Read(out int outTemplateVar) {
      byte[] b = new byte[32];
      bool ret = ReadAlignedBytes(b, 32);
      outTemplateVar = BitConverter.ToInt32(b, 0);
    //bool ret = RakNetPINVOKE.BitStream_Read__SWIG_7(swigCPtr, out outTemplateVar);
    return ret;
  }

Writing Ints:
Code: [Select]
 public void Write(int inTemplateVar) {
    //RakNetPINVOKE.BitStream_Write__SWIG_13(swigCPtr, inTemplateVar);
      Write(BitConverter.GetBytes((Int32)inTemplateVar), 32);
  }
I use the Write(byte[], int count) function for that


Now the linux server crashes with umlauts. I hate the german language :P
« Last Edit: July 13, 2012, 06:28:24 AM by Mainclain »