Binary and non-binary socketing java

I heard that there is a binary connection. I am new to java, I use plain text based on what I learned from java.sun.com tutorials for sockets. So, I want to know what are the benefits of binary socks? Why should I use this? And what resources can you offer about binary communication?

+3
source share
4 answers

You will only work with binary data through sockets, if you have a specific reason for this - for example, high performance. If you had such a reason, you would know that, and using binary data directly over sockets did not guarantee high performance.

Java , , :

.

+1

Object stream, Objects Socket Java ( , ).

Java Sun - . . /.

+3

, , . , . (XML, JSON ..) , .

+2
source

As mentioned in other answers, you should avoid socket communications if absolutely necessary. I would suggest XML as a communication data format instead of objects, as it allows you to easily communicate with clients working in other languages ​​as needed, and it is much easier to debug them. XStream is a great library to facilitate the conversion of an ↔ xml object with minimal support code.

+1
source

Source: https://habr.com/ru/post/1730301/


All Articles