B4R Question "error" log in B4R Astreams Client/ Server Tutorial

RJB

Active Member
Licensed User
Longtime User
Continued from https://www.b4x.com/android/forum/threads/b4r-sockets-astreams-initialize-errors-8266-wifi.108381/
regarding tutorial https://www.b4x.com/android/forum/threads/connecting-two-esp8266-boards.89726/#content

I've re- read and re-tested the code from the tutorial as suggested, and again get the same result. i.e. as given in the tutorial.
I still don't understand why Astream_error is called each time.
Perhaps I am just being blind or stupid but could you please explain why?
Thanks

Server:
B4X:
1
192.168.4.1
192.168.4.1
0.0.0.0
new connection
new data: hello!!!
error                    <----------------
new connection
new data: hello!!!
error                    <----------------
new connection
new data: hello!!!
error                    <----------------

Client:
B4X:
1
192.168.4.2
Trying to connect
connected
error     <---------------
 

RJB

Active Member
Licensed User
Longtime User
OK thanks, that then raises it at both ends?
Is that the only condition which calls "_error"? If not is there any way of telling what has called it?
Otherwise it looks like we just have to ignore "_error"?
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
Error event will be raised whenever the connection breaks. There isn't any other information.


Depends on your requirements.
OK thanks very much.
I'd like to put a link to this on the original thread, but it seems to be closed. It's always frustrating when a new one is started but you can't find it. Are you able to put the link on it?
Thanks
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
As far as I can see with this code the Server is set up and listening.
There is a new connection from the client and the socket/ Astream are set up.
Data is received and the socket is closed.
The error is raised and server.listen is called again.
A new connection is made from the client.
etc.
All I didn't understand was why the error was raised. Erel has explained that it is raised when you close the socket.
Seems strange but if that's the way it works then that's what we have to work with.
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
The other thread appears to be open again now so I have added a link to this one.
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
Further information:
I assumed from the above that removing the .close statement would leave the connection in tact, which it does. But I also assumed that in that state removing the power from the device at one end would break the connection and produce an error at the other.
Removing the power at the server end does, indeed, produce an error at the client end.
But, removing the power at the client end doesn't give any error at the server end, even after many minutes. Further on re-connecting the power at the client end, the client tries to connect and write and, apparently, succeeds but nothing happens at the server end.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
But, removing the power at the client end doesn't give any error at the server end, even after many minutes. Further on re-connecting the power at the client end, the client tries to connect and write and, apparently, succeeds but nothing happens at the server end.
You should start a new thread for a new question.
 
Upvote 0
Top