Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Communications > help with this vb code pls?


Reply
 
Thread Tools Display Modes
  #1  
Old 02-21-2012, 09:34 AM
pattrick_george pattrick_george is offline
Newcomer
 
Join Date: Feb 2012
Posts: 2
Unhappy 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
Reply With Quote
  #2  
Old 02-22-2012, 10:52 AM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,890
Default

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.
Reply With Quote
  #3  
Old 03-05-2012, 04:27 PM
junaidnoor junaidnoor is offline
Newcomer
 
Join Date: Mar 2012
Posts: 3
Default

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.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->