Network Programming: to maintain sockets or not?

后端 未结 7 1108
耶瑟儿~
耶瑟儿~ 2021-01-12 13:09

I\'m currently translating an API from C# to Java which has a network component.

The C# version seems to keep the input and output streams and the socket open for th

7条回答
  •  北荒
    北荒 (楼主)
    2021-01-12 13:38

    I am coming a bit late, but I didn't see anyone suggest that.

    I think it will be wise to consider pooling your connections(doesn't matter if Socket or TCP), being able to maintain couple connections open and quickly reuse them in your code base would be optimal in case of performance.

    In fact, Roslyn compiler extensively use this technique in a lot of places. https://github.com/dotnet/roslyn/search?l=C%23&q=pooled&type=&utf8=%E2%9C%93

提交回复
热议问题