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

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
 
T

Truong Hong Thi

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
 
S

SuperSentaiCollection

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top