Java socket performance bottleneck: where?

后端 未结 4 1718
面向向阳花
面向向阳花 2020-12-15 12:04

I recently started the development of an application making intensive usage of networking. A first attempt was made using RMI and for a couple of reasons, we switched over

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-15 12:31

    Found it:

    Instead of:

    out = new ObjectOutputStream(kkSocket.getOutputStream());
    

    You should use:

    out = new ObjectOutputStream(new BufferedOutputStream(kkSocket.getOutputStream()));
    

    And

    out.flush();
    

    when sending a message.

    ...makes a huge difference ...though I don't know exactly why.

提交回复
热议问题