G
Guest
Using the VB6 Winsock control in VB.NET the GetData(byRef Data as Object) method of the control returns an Object.
I have used this code that works but am not familiar with .NET arrays/object/conversions...
Private Sub wskSocketPlus_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles wskSocketPlus.DataArrival
Dim o As Object
wskSocketPlus.GetData(o)
Dim incomingDataArray() As Byte
incomingDataArray = CType(o, System.Byte())
Dim Buffer As New StringBuilder
Dim b As Byte
For element As Integer = 0 To incomingDataArray.Length - 1
b = Convert.ToByte(incomingDataArray.GetValue(element))
Buffer.Append(Chr(b))
Next element
MessageBox.Show(Buffer.ToString)
End Sub
I was told I should use string builder as it is fatser than concatination. The datapackets are around a few thosand bytes. Any suggestions as to a more correct set of conversions to give me a resulting string of the incoming Object data?
thanks, Jarrod
I have used this code that works but am not familiar with .NET arrays/object/conversions...
Private Sub wskSocketPlus_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles wskSocketPlus.DataArrival
Dim o As Object
wskSocketPlus.GetData(o)
Dim incomingDataArray() As Byte
incomingDataArray = CType(o, System.Byte())
Dim Buffer As New StringBuilder
Dim b As Byte
For element As Integer = 0 To incomingDataArray.Length - 1
b = Convert.ToByte(incomingDataArray.GetValue(element))
Buffer.Append(Chr(b))
Next element
MessageBox.Show(Buffer.ToString)
End Sub
I was told I should use string builder as it is fatser than concatination. The datapackets are around a few thosand bytes. Any suggestions as to a more correct set of conversions to give me a resulting string of the incoming Object data?
thanks, Jarrod