Find the answer to your Linux question:
Results 1 to 8 of 8
Hello! I wrote a network game using SDL_Net' and I have very weird problem, that I don't know even how to google it. The problem is that when one computer ...
  1. #1
    Just Joined!
    Join Date
    Jun 2006
    Posts
    5

    Very weird problem with SDL_Net (C)

    Hello!
    I wrote a network game using SDL_Net' and I have very weird problem, that I don't know even how to google it. The problem is that when one computer send to the other computer an address, for example 0x8100070, the second computer receive 0x7fff08100070. The second computer get the original data with addition byte - 0x7fff0. This additional byte has always this value. It solved when I upgrade from 7.10 to 8.04, but return after my program crashed. The network protocol is TCP, and it happen only in one computer (until now) - I test my program on two other computers and it run perfect. I don't have any idea what the problem could be, and it is very annoying. Does any one has an idea what the problem could be?
    Thanks,
    omer

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    In the one computer where the program fails, is that a 64-bit machine?

    And are the other computers 32-bit or 64-bit?
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Just Joined!
    Join Date
    Jun 2006
    Posts
    5
    The another computer is 32 bit, but I don't think its an endian problem, because it something SDL suppose to cover. I also check the net with another program, and anything send and receive fine except the pointer value, which is address, and this is another reason why I don't think its an endian problem.

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    I was referring not to an endian problem (whether the lowest-addressed byte is the most significant or the least significant in, say, an integer), but the word size.

    On the machine that gives you the problem, what happens when you run this?
    Code:
    #include <stdio.h>
    
    int main(void)
    {
      printf("%d\n",sizeof(int));
    
      return 0;
    }
    ... and what happens when you run it on the other machines?
    --
    Bill

    Old age and treachery will overcome youth and skill.

  5. #5
    Just Joined!
    Join Date
    Jun 2006
    Posts
    5
    Yeah, there is a different between the computers. But this different is also when i declare a variable as an Uint16, which suppose to take care of this kind of problems. How can I solve this problem?

  6. #6
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Your difficulty is not with integers, but with addresses. Declaring integers to be Uint16 does not take care of the size of addresses.

    Why are you passing main memory addresses from one machine to another?
    --
    Bill

    Old age and treachery will overcome youth and skill.

  7. #7
    Just Joined!
    Join Date
    Jun 2006
    Posts
    5
    I need to send address because I want to send a list from one computer to another. I use the adress to sign the list end - when the second computer gets the NULL address, the recieve process end. I know there are other ways to done this, but this the best way, as much as I know.

  8. #8
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    So the only thing the receiving computer is doing with the address is to test whether it's NULL?

    Then don't send addresses at all. Send a Uint16. If it's 1, then there's more to come in the list. If it's 0, there's not.
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

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