I'm a new user for basic4android.
I used a computer program (Server) that developed winsock control with vb6.
I try to connect to my program on Computer with client android software. Connection and sending data from client (android) to server is fine.
Now I want to receive message (text) that send from my computer program. How can I solve it?
Thanks.
Sub Process_Globals
Dim CltSock As Socket
Dim Astreams As AsyncStreams
Dim ip As String : ip = "192.168.0.104"
Dim port As Int: port = 12345
End Sub
Sub Globals
Dim btn_client As Button
Dim lbl_status As Label
Dim EditText1 As EditText
Dim txt_out As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("ClientForm")
EditText1.Text = ip
End Sub
Sub AStreams_NewData (Buffer() As Byte)
Dim msg As String
msg = BytesToString( Buffer, 0, Buffer.Length, "UTF8")
lbl_status.Text = msg
End Sub
Sub btn_client_Click
CltSock.Initialize("Client")
CltSock.Connect(ip,port,20000)
End Sub
Sub Client_Connected(ConStatus As Boolean)
If ConStatus = True Then
Msgbox("Connection Successful","")
Astreams.InitializePrefix(CltSock.InputStream, False, CltSock.OutputStream, "AStreams")
Else
Msgbox(LastException.Message, "Error connecting")
End If
End Sub
Sub EditText1_EnterPressed
ip = EditText1.Text
End Sub
Sub txt_out_EnterPressed
If Astreams.IsInitialized = False Then Return
If txt_out.Text.Length > 0 Then
Dim sNewLine As String
sNewLine = txt_out.text & CRLF
Dim buffer() As Byte
buffer = sNewLine.GetBytes("UTF8")
Astreams.Write(buffer)
ToastMessageShow("Sending:" & sNewLine,False)
End If
End Sub
I used a computer program (Server) that developed winsock control with vb6.
I try to connect to my program on Computer with client android software. Connection and sending data from client (android) to server is fine.
Now I want to receive message (text) that send from my computer program. How can I solve it?
Thanks.
Sub Process_Globals
Dim CltSock As Socket
Dim Astreams As AsyncStreams
Dim ip As String : ip = "192.168.0.104"
Dim port As Int: port = 12345
End Sub
Sub Globals
Dim btn_client As Button
Dim lbl_status As Label
Dim EditText1 As EditText
Dim txt_out As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("ClientForm")
EditText1.Text = ip
End Sub
Sub AStreams_NewData (Buffer() As Byte)
Dim msg As String
msg = BytesToString( Buffer, 0, Buffer.Length, "UTF8")
lbl_status.Text = msg
End Sub
Sub btn_client_Click
CltSock.Initialize("Client")
CltSock.Connect(ip,port,20000)
End Sub
Sub Client_Connected(ConStatus As Boolean)
If ConStatus = True Then
Msgbox("Connection Successful","")
Astreams.InitializePrefix(CltSock.InputStream, False, CltSock.OutputStream, "AStreams")
Else
Msgbox(LastException.Message, "Error connecting")
End If
End Sub
Sub EditText1_EnterPressed
ip = EditText1.Text
End Sub
Sub txt_out_EnterPressed
If Astreams.IsInitialized = False Then Return
If txt_out.Text.Length > 0 Then
Dim sNewLine As String
sNewLine = txt_out.text & CRLF
Dim buffer() As Byte
buffer = sNewLine.GetBytes("UTF8")
Astreams.Write(buffer)
ToastMessageShow("Sending:" & sNewLine,False)
End If
End Sub