Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.visual.basic    |    MS Visual Basic discussions, NOT dot-net    |    10,840 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 9,051 of 10,840    |
|    Steve Gerrard to Shell    |
|    Re: SV: Winsock what did I miss?    |
|    04 Dec 04 14:35:41    |
      From: mynamehere@comcast.net              "Shell" <___computerNOSPAMconsultant@mindspring.com___> wrote in message       news:oia4r0dirualqagflt1bm9ijvi9spdjvn8@4ax.com...       | >| When receiving to a string, it works.       | >| So, the quiz stands. What have I missed when trying the byte array.              | >| Private Sub Wsock_DataArrival(ByVal bytesTotal As Long)       | >| Dim byteData(256) As Byte       | >              | >I suspect that GetData is expecting a dynamic array, which it can       resize       | >to fit the data. So just doing       | > Dim byteData() As Byte       | >might do it.              | No sir, the GetData is somewhat like the Get/Input statements. They       | require "sizing" to the amount of data to be received, and a ByteArray       | is just fine for this purpose.       |              Good theory, but in fact incorrect. The examples in MSDN use unsized       strings, for instance, to receive text data, which gives a hint.              The following does work for receiving 4 bytes of data:              Private Sub Winsock3_DataArrival(ByVal bytesTotal As Long)        Dim bytes() As Byte        Dim n As Integer               Winsock3.GetData bytes, vbArray + vbByte        For n = LBound(bytes) To UBound(bytes)        Debug.Print n, bytes(n)        Next n              End Sub              If you replace the Dim statement with        Dim bytes(0 to 3) As Byte              the bytes will remain all zero.              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca