I want send one text file from device to desktop through the network.
I have this program that receive text file under Basic4PPC and works well:
This code read:
. first byte
. size of the file
. name of the file
. the file
Now i am trying to send one txt file from the android device to desktop but only this code not works:
Please can someone help me?
I have this program that receive text file under Basic4PPC and works well:
B4X:
Sub tmrWaitForData_Tick 'Checks the DataAvailable property
'If data is available then the other computer is sending a file.
If Client.DataAvailable = True Then
tmrWaitForData.Enabled = False
binary1.New1(Client.GetStream,False)
binary1.ReadByte 'Read the first byte
size = binary1.ReadInt64 'The size of the file.
If size = 0 Then 'The user pressed cancel.
tmrWaitForData.Enabled = True
Return
End If
name = binary1.ReadString 'The name of the file.
name = "text.txt" 'The name of the file.
size=10
label1.Text = "Receiving " & name & " Size: " & size
If FileExist(name) = True Then FileDel(name)
FileOpen(c1,name,cRandom)
fileStream.New1(c1,False)
Do Until size = 0
count = binary1.ReadBytes(buffer(),8192)
..................
. first byte
. size of the file
. name of the file
. the file
Now i am trying to send one txt file from the android device to desktop but only this code not works:
B4X:
Sub Process_Globals
Dim Socket1 As Socket
End Sub
Sub Activity_Create(FirstTime As Boolean)
Socket1.Initialize("Socket1")
Socket1.Connect("192.168.1.10" , 5007, 20000)
Activity.LoadLayout("1")
ToastMessageShow("Connected", True)
End Sub
Sub SendData
Dim In As InputStream
IN = File.OpenInput(File.DirRootExternal, "test.txt")
File.Copy2(IN, socket1.OutputStream)
End Sub