Valhalla Legends Forums Archive | General Programming | Visual Basic 6 - Winsock API

AuthorMessageTime
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.
[code]
COMMAND_NUMBER + " " + DATA
[/code]
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! [code][/code]
June 8, 2003, 5:49 PM
Noodlez
[me=Noodlez]shows interest[/me]
June 8, 2003, 8:18 PM
TheMinistered
Just for you nub, oops I mean noodlez! here is the link: http://www27.brinkster.com/wsckvbupdates/default.html :)
June 8, 2003, 11:18 PM
Noodlez
eh, it's nothing special... well, the winsock class is pretty neat.
June 9, 2003, 3:09 AM
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
June 9, 2003, 3:29 AM
Camel
[quote author=TheMinistered link=board=5;threadid=1578;start=0#msg11911 date=1055129389]
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
[/quote]

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

[code]
...
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)))
...[/code]
June 9, 2003, 10:19 PM
Skywing
[quote author=Camel link=board=5;threadid=1578;start=0#msg11942 date=1055197142]
[quote author=TheMinistered link=board=5;threadid=1578;start=0#msg11911 date=1055129389]
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
[/quote]

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

[code]
...
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)))
...[/code]
[/quote]
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...
June 9, 2003, 10:30 PM
Camel
[quote author=Skywing link=board=5;threadid=1578;start=0#msg11943 date=1055197826]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...[/quote]
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.
June 9, 2003, 10:37 PM
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...
June 10, 2003, 2:51 AM
TheMinistered
[quote] it's nothing compared to my mechanical port of checkrevision() [/quote]
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.
June 10, 2003, 5:23 PM
MesiaH
I wonder who that friend could be? ^^
June 10, 2003, 7:32 PM
Camel
[quote author=TheMinistered link=board=5;threadid=1578;start=0#msg11998 date=1055265822]
[quote] it's nothing compared to my mechanical port of checkrevision() [/quote]
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[/quote]
porting checkrevision to vb is harder than use pure sockets in vb. 'nuf sed.

[quote author=TheMinistered link=board=5;threadid=1578;start=0#msg11998 date=1055265822]
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.
[/quote]
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?
June 10, 2003, 8:28 PM
TheMinistered
[code]
660EA517 __vbaLenBstrB: ; note the shift is missing here
[/code]

That came directly from an earlier post. Please take notice of the "str".
June 10, 2003, 9:21 PM
kamakazie
[quote author=Camel link=board=5;threadid=1578;start=0#msg12008 date=1055276906]
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?
[/quote]

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.
June 10, 2003, 11:13 PM
Camel
[quote author=kamakazie link=board=5;threadid=1578;start=0#msg12039 date=1055286810]
[quote author=Camel link=board=5;threadid=1578;start=0#msg12008 date=1055276906]
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?
[/quote]

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.
[/quote]

that would probably explain it
i was just using a plain string
June 10, 2003, 11:26 PM
TheMinistered
lol, camel, always taking the first answer and not logically thinking through it aye?

visual basic strings are unicode. I doubt you passed in a different "type" of string.

LenB works by grabbing the BSTR header and returning it. Len works by grabbing the BSTR header, shifting right by one (dividing by two effectively...) and returning.
June 11, 2003, 2:35 AM
Camel
[quote author=TheMinistered link=board=5;threadid=1578;start=15#msg12062 date=1055298934]
lol, camel, always taking the first answer and not logically thinking through it aye?

visual basic strings are unicode. I doubt you passed in a different "type" of string.

LenB works by grabbing the BSTR header and returning it. Len works by grabbing the BSTR header, shifting right by one (dividing by two effectively...) and returning.
[/quote]

i believe you, but something has going on to make lenb take longer than len
June 11, 2003, 10:20 PM
St0rm.iD
It's not hard to port CheckRevision if you've written expression evaluators before. You don't even need to implement order of operations!
June 11, 2003, 11:51 PM
Camel
[quote author=St0rm.iD link=board=5;threadid=1578;start=15#msg12133 date=1055375508]
It's not hard to port CheckRevision if you've written expression evaluators before. You don't even need to implement order of operations!
[/quote]

i never said it was
the point is i'm using pointers in vb...and it's ultra slow :D
June 11, 2003, 11:53 PM
St0rm.iD
Don't need to use pointers.
June 12, 2003, 12:30 AM
Camel
[quote author=St0rm.iD link=board=5;threadid=1578;start=15#msg12139 date=1055377803]
Don't need to use pointers.
[/quote]
who is filling your head with this stuff? nobody ever said pointers are required. that's why it's a mechanical port! i know it's not efficient--i dont even use it!
June 12, 2003, 2:26 AM

Search