recv() socket function returning data with length as 0

后端 未结 8 2084
甜味超标
甜味超标 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:36

    I suppose you're using TCP to communicate with your device.

    1. The socket itself is still "valid", however the the connection was lost.

    2. You get a return value of 0 for recv() when the connection was closed by the other host (wether this disconnection was graceful or not doesn't matter)

    3. socket functions are like C functions: they don't throw because they can be used in C programs, where exceptions do not exist.

提交回复
热议问题