Results 1 to 14 of 14

Thread: [HELP NEEDED] Socket + UDT + CopyMemory...

Hybrid View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    Re: [HELP NEEDED] Socket + UDT + CopyMemory...

    Your code is rather similar to what I already do, with just some slight differences . For example instead of global variables I use static ones as already pointed out, and I don't use two different byte arrays for the data treatment.

    Quote Originally Posted by ccoder
    One quick question about the longs and integers in your UDT; are they big-endian (aka network byte order)? If so, you will need to use the API functions to convert to little-endian. You can see this in the DataArrival code in the above link. The C app that the code in the link connects to runs on another platform that is big-endian. Java, by default, converts values to big-endian. We always send values in big-endian and leave it to the receiving end to convert accordingly.
    Yes, I have to, and already, make big<->little conversions.

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177

    Re: [HELP NEEDED] Socket + UDT + CopyMemory...

    Quote Originally Posted by Neverbirth
    Your code is rather similar to what I already do, with just some slight differences . For example instead of global variables I use static ones as already pointed out, and I don't use two different byte arrays for the data treatment.
    In your original post you stated
    Currently I use a static byte array (static because some of the messages are rather large and arrive in several packages), and once I know I've received the whole message I use copymemory with a UDT, and treat it...
    but, from the few lines that you posted, it appears that you always receive the incoming data into the static byte array, copy it to the UDT and then clear it. It isn't clear that you are preserving the data until all of it has arrived.

    I used a global byte array because the entire UDT does not arrive in one piece. The other byte array was used for the .GetData and then I used copyPtr to move the receiving byte array to the appropriate position in the final byte array. I don't recall why I used a global for the initial receive.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    Re: [HELP NEEDED] Socket + UDT + CopyMemory...

    Quote Originally Posted by ccoder
    In your original post you stated
    but, from the few lines that you posted, it appears that you always receive the incoming data into the static byte array, copy it to the UDT and then clear it. It isn't clear that you are preserving the data until all of it has arrived.

    I used a global byte array because the entire UDT does not arrive in one piece. The other byte array was used for the .GetData and then I used copyPtr to move the receiving byte array to the appropriate position in the final byte array. I don't recall why I used a global for the initial receive.
    ? That's why I use static variables, because that way they keep their values when the data arrives in several packages. I check if the data is the continuation from a previous one, and if so I keep the data until it finishes coming, and then erase the static array for new data.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width