Results 1 to 9 of 9

Thread: How to get the high bit /low bit order?

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    How to get the high bit /low bit order?

    I have for example the number 3021 that should have a high bit of 30 and low bit 21. How can I do this? I need it to do an FTP listing thing.

    here is the thing from where i'm reading from :
    This address information is broken into 8-bit fields and the value of each field is transmitted as a decimal number (in character string representation). The fields are separated by commas.
    http://www.vbip.com/winsock/winsock_ftp_ref_02.asp

    Thanks in advance
    \m/\m/

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Do you mean big-endian and little-endian? Like you're sending integers from a Windows machine to a Unix machine? If so then this thread might help. http://vbforums.com/showthread.php?s=&threadid=264947

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    I don't really know if what they are saying in that topic is what I am asking about as I don't even have a very accurate idea of what it really is (LOL). I think it has something to do with the LOWORD()/HIWORD() macros(?) in c++

    About the topic it requires api's and I'd like to go through the .net way
    \m/\m/

  4. #4
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    It would be nice if they had an example. But from reading that, it sounds like for your port of 3021 you'd send a char that equals 30 and a char that equals 21, separated by commas.

    Just a guess, friend.

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    To deliver port 3021 i have to send "30,21"

    30's binary string + 21's binary string = 3021's binary string. I can understand this but I don't understand how to achieve the opposite.
    \m/\m/

  6. #6
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Not sure if I understand you right. You're not going to send "30,21", because that would be sending four 8-bit fields (plus the comma). I think it means you'd send "," - or in hex 0x1E,0x15.

    0x1E = 30, 0x15 = 21

    Of course, I'm probably wrong.

  7. #7

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Yes you're wrong. They will be sent with the ip bytes separeted by comas more the port (the two values i want to know how to get separeted by comas)

    The thing is how am i going to get the damn 8-bit port values?

    Take the following as example:
    Code:
        PORT 213,13,237,218,18,27
    200 Port command successful.
        Opening data connection IP: 213.13.237.218 PORT: 4635.
    Last edited by PT Exorcist; Mar 31st, 2004 at 08:48 PM.
    \m/\m/

  8. #8
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Yes you're wrong.
    That made me lol. Too funny.

    The example helps. Haven't tried any code (not even sure if I know how) but it's pretty easy to get to the bits and bytes of it.

    In your previous post, it looks like port 4635 = 18,27. Let's get it on...

    4635 in binary = 1001000011011

    Take the right 8 bits = 00011011 = 27
    Take the left 8 bits (left pad with zeros) = 00010010 = 18

    You can leave the right 8 bits alone, but need to multiply the left 8 bits by 256 because they're shifted left 8 bits.

    So now you have 27 + (18 * 256) = 4635

    Of course, I may be wrong.

    Mike

  9. #9

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Yeah I think that it is. Ill try it this night when i get back home
    \m/\m/

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