recv() socket function returning data with length as 0

后端 未结 8 2066
甜味超标
甜味超标 2020-12-24 07:55

I am having an application which established a socket connection on a port number 5005 with another device(hardware device with a web server).

Now if my hardware de

8条回答
  •  [愿得一人]
    2020-12-24 08:41

    If recv returns 0 this means that the peer has closed the socket.

    recv won't throw because its a C function.

    If there's an error recv will return -1. In which case your application has to check the type of error. Note that a return of -1 does not imply that the peer has closed its socket.

提交回复
热议问题