 |

02-21-2012, 09:34 AM
|
|
Newcomer
|
|
Join Date: Feb 2012
Posts: 2
|
|
help with this vb code pls?
|
Hi there ,
I am looking in to a source code of yahoo messenger clone in vb6.0 , so obviously its winsock programming
so in The yahoo messenger header for yahoomessenger packet i see this declaration in the module,
Code:
YMSGPacket = "YMSG" & Chr(Int(Version / 256)) & Chr(Int(Version Mod 256)) & String(2, Chr(1)) & Chr(Int(Len(StrPacketType) / 256)) & Chr(Int(Len(StrPacketType) Mod 256)) & Chr(Int(StrComm / 256)) & Chr(Int(StrComm Mod 256)) & Mid(StrStat, 1, 4) & Mid(StrSession, 1, 4) & StrPacketType
tht code is the code which is sent through the winsock , I have a few more questions ,in what format is data senthrough winsockcomponent of visualbasic , string , hex ,binary or ascii
i see the mod 256 and / 256 code everywhere in this program , whats use of this statement
another code
Code:
TimSt = Chr$((((number And &HFF000000) / 256) / 256) / 256) & Chr$(((number And &HFF0000) / 256) / 256) & Chr$((number And &HFF00&) / 256) & Chr$(number And &HFF&)
every help would be greatly appreciated
thanks in advance  
|
|

02-22-2012, 10:52 AM
|
 |
Sinecure Expert
Super Moderator * Guru *
|
|
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,714
|
|
The winsock component will transmit an array of bytes.
An ASCII string is esentially an array of bytes, just treated differently in how you access it, so you can send an array of bytes to the socket in the format of an array of bytes, or a string.
A string in VB is actually stored as Unicode by VB in memory, but will be converted to an ASCII string (essentially an array of bytes) before it transmits it.
The mod function will give you the "remainder" after doing an Integer divide.
i.e.
10 mod 256 is 10,
192 mod 256 is 192
256 mod 256 is 0
257 mod 256 is 1
513 mod 256 is 1
etc...
A byte (8 bits) will contain the value 0 to 255, so using mod 256 will give you the value of the Least Significant Byte (LSB) of a number.
Likewise, dividing by 256 will "shift" the bits in a number "to the right", or "towards the LSB" by 8 bits (i.e. 1 byte),
so you can access the value of specific bytes in a number by using various combinations of Mod, /, and "And mask", i.e. "And &HFF".
See the Bits, Bytes, and Bases tutorial.
.
|
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
|

03-05-2012, 04:27 PM
|
|
Newcomer
|
|
Join Date: Mar 2012
Posts: 3
|
|
Nice explanation passel  .
And pattrick these are actually some encryption routines by yahoo, so if you are making your own messenger instead of a chat client for yahoo then well you can use your own encryption routines, you don't need to use the same routine as yahoo for making an instant messenger.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|