how to receive data from .NET socket into VB6 winsock ?

  • Thread starter Thread starter cadriansyah
  • Start date Start date
C

cadriansyah

i have a socket apllication written in .NET (VB) that send data
(microsoft sample)

Public Sub SendData(ByVal Data As String)
' Synclock ensure that no other threads try to use the stream
at the same time.
SyncLock client.GetStream
Dim writer As New IO.StreamWriter(client.GetStream)
writer.Write(Data & Chr(13) & Chr(10))

' Make sure all data is sent now.
writer.Flush()
End SyncLock
End Sub
.....
.....
client.SendData(strMessage)
.....
.....
# but when i receive from vb6 application #

Public Sub sockMain_DataArrival(ByVal bytesTotal As Long)

Dim strData As Variant
MDIForm1.sockMain.GetData strData

If Not IsNull(strData) Then
MsgBox strData
End If

End Sub

it returns NUMBER (numerical value)
what does it mean ?
how do i translate it ?

how do i find an equivalent function as thi one :
strMessage = Encoding.ASCII.GetString(readBuffer, 0, BytesRead - 2)

thank you
 
I suggest you try like this:
When sending:
Dim writer As New IO.StreamWriter(client.GetStream, Encoding.ASCII)

When receiving:
Dim strData As String
MDIForm1.sockMain.GetData strData, vbString
 
it works !

thank you very much.

I suggest you try like this:
When sending:
Dim writer As New IO.StreamWriter(client.GetStream, Encoding.ASCII)

When receiving:
Dim strData As String
MDIForm1.sockMain.GetData strData, vbString
 
Back
Top