Android Question Socket server broke connection

Zlgo

Member
Found problem with using ServerSocket example where two identical "client-server" application on two separate PC breaks communication if speed of sending data is faster. Rule is that on remote side server close connection by himself, but on client side this is not detected by event just (debug mode) trow:

java.net.SocketException: socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at java.net.SocketInputStream.read(SocketInputStream.java:127)
at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:199)
at java.lang.Thread.run(Thread.java:748)
java.net.SocketException: Socket closed
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
at java.net.SocketOutputStream.write(SocketOutputStream.java:143)
at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AOUT.run(AsyncStreams.java:338)
at java.lang.Thread.run(Thread.java:748)

Is there some speed limitation for communication over socket or is some glitch in code or in java?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Not sure which example you are referring to however it is possible that it wasn't built to support multiple connections.

There are two examples that demonstrate multiple connections, though in most cases it is a mistake to use the low level sockets instead of a higher level solution (jServer, MQTT and others).

[B4X] FTP Server implemented with Socket and AsyncStreams
MJPEG / CCTV Server
 
Upvote 0

Zlgo

Member
This is app made from examples for socket connection based on ServerSocket and Socket . Problem occur in simple test where just one client on one pc send messages on other pc server. Sending short string like"123" from text field on press enter, made closing receiving server without any event on server side, and activating server again connection works till next speed burst of data. Maybe also that in my app is some misusing details! How I notice this braking connection is with help of micro switch button which made quick on/off state in one push and he's state is send to server but this quick burst of data crash connection.
 
Upvote 0

Zlgo

Member
I'm trying to post code , but every time he disappear.
I've sent you a private message and I'm waiting for your reply.
 
Last edited by a moderator:
Upvote 0
Top