Read and Write Bytes data packet via socket

后端 未结 1 1493
面向向阳花
面向向阳花 2021-01-24 08:28

I want to connect Android Device to external device via Socket. Socket Connect to external device successfully.

Now if any data require from external device then send re

1条回答
  •  梦毁少年i
    2021-01-24 09:24

    You're doing this the hard way. Get rid of the ByteBuffer altogether and use all the methods of DataOutputStream. They are all big-endian. I can't see any mistake but clearly you must be sending something the peer didn't understand so he is closing the connection instead of sending a reply.

    Note: Socket.isConnected() cannot possibly be false at the point you're testing it.

    0 讨论(0)
提交回复
热议问题