|
-
Mar 31st, 2004, 04:17 PM
#1
Thread Starter
yay gay
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/
-
Mar 31st, 2004, 05:24 PM
#2
Frenzied Member
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
-
Mar 31st, 2004, 05:54 PM
#3
Thread Starter
yay gay
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/
-
Mar 31st, 2004, 06:10 PM
#4
Frenzied Member
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.
-
Mar 31st, 2004, 06:16 PM
#5
Thread Starter
yay gay
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/
-
Mar 31st, 2004, 06:22 PM
#6
Frenzied Member
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.
-
Mar 31st, 2004, 08:44 PM
#7
Thread Starter
yay gay
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/
-
Mar 31st, 2004, 10:29 PM
#8
Frenzied Member
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
-
Apr 1st, 2004, 05:18 AM
#9
Thread Starter
yay gay
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|