Redian新闻
>
Asking for help on TCP server programming
avatar
Asking for help on TCP server programming# Unix - 噫吁兮,危乎高哉
I*s
1
Generally server recvs sth, then sends response,
and closes the connection. However sometimes it
requires the server to wait passively for the
client to shut down the connection, otherwise
server keeps connection open and waits for
client's next request. If so, what's the answer
for 1) and 2)?
Or is it that each time a new request opens a
new connection? If so, what's the answer for 2)?
1) What's the mechanism to indicate to the server
if the client has shut down connection or not?
2) And what's
avatar
w*s
2

It seems that you know nothing about socket programming.
ok, normally your program will block on command 'recv' or 'recvfrom'
so, to question 1, when the client close the connection. the recv will return
0.to question 2, when data is available on socket, recv will return with the
data length and the content of the data just received.

【在 I**********s 的大作中提到】
: Generally server recvs sth, then sends response,
: and closes the connection. However sometimes it
: requires the server to wait passively for the
: client to shut down the connection, otherwise
: server keeps connection open and waits for
: client's next request. If so, what's the answer
: for 1) and 2)?
: Or is it that each time a new request opens a
: new connection? If so, what's the answer for 2)?
: 1) What's the mechanism to indicate to the server

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