VB6 Server BASIC4PPC Client Problem

snakex

New Member
Licensed User
Longtime User
Can anyone help me on this one.

Basic4PPC

Sub button2_Click

Client.Connect (textbox1.Text,50000)

binary1.New1(client.GetStream,False)
binary1.WriteString ("Server Connected")

End Sub

Sub tmrWaitForData_Tick 'Checks the DataAvailable property



If client.DataAvailable = True Then
tmrWaitForData.Enabled = False
listbox1.Add(binary1.ReadString)
tmrWaitForData.Enabled = True
End If

End Sub

VB6


tcpserver(Index).GetData strData
tcpserver(Index).SendData txtoutput.Text


tcpserver is a winsock control


From client to server communication is fine. From server to client, one of the 3 things will happen when I click on the button to send text string to the client:


1. Nothing happens
2. All the strings appears from my previous button click will appear on the client.
3. Error : "Unable to read beyond the end of the stream" from the client


Please help. Thanks.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
BinaryFile.WriteString and ReadString can only be used with other .Net programs (including Basic4ppc).
WriteString first writes the string length and then writes the string. ReadString expects this protocol.
In order to just send the string you will need to first convert it to a bytes array and then send the bytes array.

I'm not familiar with VB6 protocol. You will need to check what is the exact protocol that VB6 expects.
 

snakex

New Member
Licensed User
Longtime User
Thanks for the help.

Works now.

VB6 Server

tcpserver(1).SendData AsciiToUTF8("test1234" & vbCrLf)


BASIC4PPC Client

binary1.ReadBytes(buffer(), 10)
listbox1.Add(binary1.BytesToString(buffer(),0,ArrayLen(buffer())))
 
Top