B4J Tutorial Network + AsyncStreams + B4XSerializator

This is the B4J version of this B4A example: Network + AsyncStreams + B4XSerializator
Note that B4XSerializator is cross platform, so it should be simple to use similar code to communicate with B4A or B4i programs.

SS-2017-05-15_16.59.49.png


The program implements a server and a client. The data sent is a custom type serialized (converted to bytes) with B4XSerializator.

The port is picked randomly. This is useful to allow testing it on the same computer. Run the program in release mode and run another instance from the command line.
Set the ip address to 127.0.0.1 when connecting to the same PC.

Note that you need to open a port in Windows firewall for incoming connections if you want to allow other computers to connect.
 

Attachments

  • NetworkExample.zip
    3.4 KB · Views: 827

magi6162

Well-Known Member
Licensed User
Sorry,
I've tried your example. The IP value given by the application is always 192.168.56
My network is 192.168.11.xxx
What am I doing wrong
thanks for help
 

OliverA

Expert
Licensed User
Do you have more than one active network card (LAN + WiFi, LAN + LAN, etc)?
 

magi6162

Well-Known Member
Licensed User
sorry,
If the server has 2 network cards (can not be disabled) how can I do it?

thanks for help
 

Richard Lord

Member
Licensed User
Hi All,
I just tried the NetworkExample from above and this is the result of compile:-
B4J version: 5.50
Parsing code. (0.02s)
Compiling code. (0.13s)
Compiling layouts code. (0.02s)
Organizing libraries. (0.00s)
Compiling generated Java code. Error
B4J line: 34
Try
javac 1.8.0_144
src\b4j\example\main.java:299: error: illegal '.'
this..catchState = 5;
^
1 error
Can anyone help please, do I need an update, do I have something missing, have I gone do-lally?
Thanks
 
Top