• Welcome to Valhalla Legends Archive.
 

Visual Basic 6 - Winsock API

Started by TheMinistered, June 08, 2003, 12:49 PM

Previous topic - Next topic

TheMinistered

I want to know if you guys are interested in seeing a _great_ example of a client & server that use the winsock api (via subclassing).  The client & server run on an ascii protocol and the protocol is very basic.  

Here is the basic protocol.

COMMAND_NUMBER + " " + DATA

It consists of a command number (string) that is 8 bytes long (unicode) and contains four characters.  The four characters allow for a possible (well i don't know exactly, but lets just say lots! :D) unique packet id's (is that right?).  It has a space for a delimeter, and then the data follows.

If you guys want the source to the project, then reply and tell me so.  I will post a link if I see enough interest!  It is very well organized too!  

Noodlez


TheMinistered

#2
Just for you nub, oops I mean noodlez!  here is the link:  http://www27.brinkster.com/wsckvbupdates/default.html  :)

Noodlez

eh, it's nothing special... well, the winsock class is pretty neat.

TheMinistered

You obviously didn't look @ the subclasser, ohwell, real world interaction -- it lacks ; however, the internals of the program are quite advanced for vb :D

Camel

Quote from: TheMinistered on June 08, 2003, 10:29 PM
You obviously didn't look @ the subclasser, ohwell, real world interaction -- it lacks ; however, the internals of the program are quite advanced for vb :D

it's nothing compared to my mechanical port of checkrevision() :)


...
       Dim sa As SECURITY_ATTRIBUTES
       hFile = CreateFile(FileNames(i), GENERIC_READ, FILE_SHARE_READ, sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
       If hFile = INVALID_HANDLE_VALUE Then GoTo return_FALSE
...
#Const UsePointers = True

#If Not UsePointers Then
       Dim buffer As String
       buffer = Space(dwSize)
       CopyMemory ByVal buffer, ByVal lpdwBuffer, dwSize
#End If

       For j = 0 To Int(dwSize / 4) - 1
#If UsePointers Then
           CopyMemory dwVariables(3), ByVal (lpdwBuffer + (j * 4)), 4
#Else
           dwVariables(3) = CVL(Mid(buffer, 1 + (j * 4), 4))
#End If
           For k = 0 To nHashOperations - 1
               Select Case cOperations(k)
                   Case "+": dwVariables(nVariable1(k)) = Add(dwVariables(nVariable2(k)), dwVariables(nVariable3(k)))
...

Skywing

Quote from: Camel on June 09, 2003, 05:19 PM
Quote from: TheMinistered on June 08, 2003, 10:29 PM
You obviously didn't look @ the subclasser, ohwell, real world interaction -- it lacks ; however, the internals of the program are quite advanced for vb :D

it's nothing compared to my mechanical port of checkrevision() :)


...
       Dim sa As SECURITY_ATTRIBUTES
       hFile = CreateFile(FileNames(i), GENERIC_READ, FILE_SHARE_READ, sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
       If hFile = INVALID_HANDLE_VALUE Then GoTo return_FALSE
...
#Const UsePointers = True

#If Not UsePointers Then
       Dim buffer As String
       buffer = Space(dwSize)
       CopyMemory ByVal buffer, ByVal lpdwBuffer, dwSize
#End If

       For j = 0 To Int(dwSize / 4) - 1
#If UsePointers Then
           CopyMemory dwVariables(3), ByVal (lpdwBuffer + (j * 4)), 4
#Else
           dwVariables(3) = CVL(Mid(buffer, 1 + (j * 4), 4))
#End If
           For k = 0 To nHashOperations - 1
               Select Case cOperations(k)
                   Case "+": dwVariables(nVariable1(k)) = Add(dwVariables(nVariable2(k)), dwVariables(nVariable3(k)))
...

And you've tried benchmarking this to see how unavoidably slow it is?  Considering that the pure C approach yields slow results, I doubt that a "pure VB" approach could help the performance...

Camel

#7
Quote from: Skywing on June 09, 2003, 05:30 PMAnd you've tried benchmarking this to see how unavoidably slow it is?  Considering that the pure C approach yields slow results, I doubt that a "pure VB" approach could help the performance...
who said it was efficient? certainly not me.
the point is that it can be done, not that it's worth doing :)

[edit] and isn't "pure vb" an oxymoron?
[edit2] it only takes about 1600ms where the c version takes about 30. so it only takes 50 or 60 times longer =P.

indulgence

why a unicode string for header.  You could just as simply do it binarily and use a WORD for a header, and save 6 bytes... I wouldn't imagine any project requiring more than that for Packet IDs.  I mean a byte would arguably be enough.  Just use public constants to make the binary header more understandable when you are coding, it would accomplish the same task, and cut down on packet size...
<3

TheMinistered

#9
Quoteit's nothing compared to my mechanical port of checkrevision()
I don't see how you can compare that to my project, but ok!  I don't see how your's is that "advanced"... and I'm glad that you understand c++ and visual basic well enough to convert it from c++ to vb.  I think you deserve a prize.  However, I have a faster implementation of BnetAuth that can be called locally in visual basic too.   A friend and I converted BnetAuth.DLL into a class module that uses a hack-around to execute machinecode.  Good Game

Oh, and I would not trust his "timer", because he told me Len() was faster than LenB() and actually showed me "timed" results that "proved" len was faster then lenb.  However, I showed him the disassembly and it was, infact, impossible for Len to be faster than LenB.

Mesiah / haiseM

I wonder who that friend could be? ^^
]HighBrow Innovations
Coming soon...

AIM Online Status: 

Camel

Quote from: TheMinistered on June 10, 2003, 12:23 PM
Quoteit's nothing compared to my mechanical port of checkrevision()
I don't see how you can compare that to my project, but ok!  I don't see how your's is that "advanced"... and I'm glad that you understand c++ and visual basic well enough to convert it from c++ to vb.  I think you deserve a prize.  However, I have a faster implementation of BnetAuth that can be called locally in visual basic too.   A friend and I converted BnetAuth.DLL into a class module that uses a hack-around to execute machinecode.  Good Game
porting checkrevision to vb is harder than use pure sockets in vb. 'nuf sed.

Quote from: TheMinistered on June 10, 2003, 12:23 PM
Oh, and I would not trust his "timer", because he told me Len() was faster than LenB() and actually showed me "timed" results that "proved" len was faster then lenb.  However, I showed him the disassembly and it was, infact, impossible for Len to be faster than LenB.
yeah i've noticed that too. len is *clearly* faster (although not by a whole hell of a lot) than lenb in practical application; perhaps it's because lenb() accepts variants/objects?

TheMinistered


660EA517                    __vbaLenBstrB:      ; note the shift is missing here


That came directly from an earlier post.  Please take notice of the "str".

dxoigmn

Quote from: Camel on June 10, 2003, 03:28 PM
yeah i've noticed that too. len is *clearly* faster (although not by a whole hell of a lot) than lenb in practical application; perhaps it's because lenb() accepts variants/objects?

What are you taking the length of?  If it's a string, did you StrConv(myString, vbFromUnicode) it first?  Strings in Visual Basic are unicode and this could be a major source of error in your benchmarks.

Camel

Quote from: kamakazie on June 10, 2003, 06:13 PM
Quote from: Camel on June 10, 2003, 03:28 PM
yeah i've noticed that too. len is *clearly* faster (although not by a whole hell of a lot) than lenb in practical application; perhaps it's because lenb() accepts variants/objects?

What are you taking the length of?  If it's a string, did you StrConv(myString, vbFromUnicode) it first?  Strings in Visual Basic are unicode and this could be a major source of error in your benchmarks.

that would probably explain it
i was just using a plain string