Redian新闻
>
有人用过异步Socket么?
avatar
有人用过异步Socket么?# Java - 爪哇娇娃
D*s
1
有没有可能non-blocking socket和Stream一起用呢?
还有UDP可以用Stream么?
avatar
f*g
2

Yes you can. But it is better using nio. The best, it is
still use tradition Java socket. NB Socket's performance
is too bad.

【在 D*********s 的大作中提到】
: 有没有可能non-blocking socket和Stream一起用呢?
: 还有UDP可以用Stream么?

avatar
D*s
3
Where did you get the data saying that NB Socket's performance
is bad? any link please.
You said I can use non-blocking socket along with Stream. Can you
please tell some details?
As I know if you don't use nio, which has select(), you actually
can't use non-blocking socket because busy waiting is a BAD idea.
Did you just refer to this busy waiting when you said NB socket's
performance?

【在 f*****g 的大作中提到】
:
: Yes you can. But it is better using nio. The best, it is
: still use tradition Java socket. NB Socket's performance
: is too bad.

avatar
e*g
4
short answer: no. no such API/adapter.
middle answer: don't use socket channel, mostly you don't need it,
it just makes your program complicated without visible performance
gain. keep code simple and scalable, put more servers, it's cheap.
long answer: if you do reach some kind of limit and you must use
socket channel. sure you can write your own plumbing and make
adapters of channel->stream, but then you end up with thousands
of threads and defeat the purpose of select(). in this

【在 D*********s 的大作中提到】
: Where did you get the data saying that NB Socket's performance
: is bad? any link please.
: You said I can use non-blocking socket along with Stream. Can you
: please tell some details?
: As I know if you don't use nio, which has select(), you actually
: can't use non-blocking socket because busy waiting is a BAD idea.
: Did you just refer to this busy waiting when you said NB socket's
: performance?

avatar
D*s
5
This makes sense. Thanks.

【在 e***g 的大作中提到】
: short answer: no. no such API/adapter.
: middle answer: don't use socket channel, mostly you don't need it,
: it just makes your program complicated without visible performance
: gain. keep code simple and scalable, put more servers, it's cheap.
: long answer: if you do reach some kind of limit and you must use
: socket channel. sure you can write your own plumbing and make
: adapters of channel->stream, but then you end up with thousands
: of threads and defeat the purpose of select(). in this

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。