Receive an object over TCP/IP

后端 未结 3 1569
渐次进展
渐次进展 2021-01-19 23:35

I am going to write a program over TCP/IP and I should send objects by client or by server, It is going right when I want to send or receive strings but when I am trying to

3条回答
  •  不要未来只要你来
    2021-01-20 00:10

    If you'd like to achieve good performance and send object then you definitely should use Google Protobuf

    It allows you to define messages in simple .proto files. Then you use bundled compiler to generate Java classes which will be serialized and sent.

    Also better idea is to use Netty over plain Java sockets. This prevent you from writing a lot of boilerplate code and define simple serialization/deserialization pipelines. Take a look at user-guide.

提交回复
热议问题