Android Question Send string to IP adress

besoft

Active Member
Licensed User
Longtime User
Hello,
I have onequestion:
From Android device I would like to send a string to an IPaddress.The forum I found such ClientSocet, but does not work as expected.
When sending a string to an IPaddress,some times it arrives at an IPaddress,many times do not..or delayed.
What do you advise on how to get started?.
I'm starting to learn about Basic4Android
 

besoft

Active Member
Licensed User
Longtime User
Thanks for the replies.

I tried also to the second case (for example, by pasted rbsoft) and the result is the same.
Server is configured as a TCP server. It's WiFi to RS232 module wiznet.

Wiznet module I have tested with other devices, as well as computer and communication works without problems and reliably.

I tried to phone the Samsung Galaxy XCOVER and Android tablet I-inn. On both running Android 4
Communication is established without problems the first few strings sent good, others are not. In the meantime, send any string as well. When interrupt communication on the side of Android, then arrive all previously transmitted string, which has not previously received. It is also in the opposite direction, the response from the wiznet module comes later and is also more strings together. Always get a double. So if you send a string from the server "TEST" in the android apps I stirng "TEST" is written as:
TEST
TEST

I suspect that something is happening with the buffer on the side of Android applications.

Thanks
 
Upvote 0

besoft

Active Member
Licensed User
Longtime User
The module does not require any special character at the end. Sometimes in other applications use only a CR and LF character, but not necessarily.
 
Upvote 0

besoft

Active Member
Licensed User
Longtime User
Hello,Please find attached the program that acts as a server and listened on port 5000

I tried to communicate with the program, the connection is established, but sent string can arrive to the server.
I would like to solve various problems with communication with Android devices.I think the problem is the same as the wiznet module.
Please,if you can test the program,I can not find solutions.
Thanks
link : http://www.be-soft.net/wb/media/Server.zip
 
Upvote 0

besoft

Active Member
Licensed User
Longtime User
At the end of the string I added a CR and LF. Now works well.
in the terminal I sign appears FE (format effector). How can I get rid of this character. The code is attached as a few posts (example) earlier.
Thanks
 
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
This is the code that sends the data to the server:

B4X:
Sub SendData(msg As String)
    Dim Buffer() As Byte

    Buffer = msg.GetBytes("UTF8")
    AStreams.Write(Buffer)
    AStreams.Write(Array As Byte(254))

End Sub

Note the line
AStreams.Write(Array As Byte(254))

Remove this line, that should solve your problem. It was for compatibily with an older EVB app only. Chr(254) was used as an end delimiter in the protocol.

Rolf
 
Last edited:
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
Great!
 
Upvote 0
Top