Android Tutorial [B4X] Network + AsyncStreams + B4XSerializator

Not open for further replies.
Better implementation, based on B4XPages:

New video tutorial:




This is a simple and important example. It demonstrates several good practices related to network communication.

1. The network related code is in the Starter service. The network state is also stored in the starter service.
2. The Activity is only responsible for the UI.
3. Using B4XSerializator it is simple to work with types instead of strings or bytes. In this case the message structure is:
Type MyMessage (Name As String, Age As Int, Image() As Byte)
- Bitmaps cannot be directly serialized so we need to convert the bitmap to bytes and vice versa.
- B4XSerializator is cross platform compatible. This means that you can send the exact same structure to B4J or B4i applications.

Platform specific notes

- The code in B4J and B4i is a bit simpler as there is no need to use a second module (starter module). All modules are always active in B4J and B4i.
- In B4i we need to recreate the server socket when the application becomes active as the socket can become stale while the app is in the background (and not killed).
- Windows firewall blocks incoming connections so if you want to connect to the B4J app, you need to first allow incoming communication on the relevant port.


    4.8 KB · Views: 1,624
    4.4 KB · Views: 2,710
    9.2 KB · Views: 2,104
    9.2 KB · Views: 4,821
Last edited:


Active Member
Licensed User
i try use this NETWORK libary connect to ROUTER by SSH ,I have looked by log ,it is connect succus , buy i can not send command by
CallSub2(Starter, "SendData", data2.GetBytes)

in telnet mode ,this work good. when i change to 22 PORT , this not work now .can you help me ?
Not open for further replies.