C++ Functions According to TCP

后端 未结 1 1681
青春惊慌失措
青春惊慌失措 2021-01-16 22:37

I\'m using recv function (C++) in order to get indication about network problem (it return negative value in this case)

Looking here: http://tools.ietf.org/html/rfc1

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-16 23:14

    On most systems, recv() transmit informations by two means : the return code and by setting the global variable errno.

    To know what is returned/set in each case, you have to look at the exact API of the recv() function.

    • R1 (problem) : recv() returns SOCKET_ERROR (windows) or -1 (linux), then you look at the value from WSAGetLastError (windows) or errno (linux) for details
    • R2 (connexion closed) : I'm not sure, the API is unclear. Just try it out ;-)

    Full doc :

    • windows : http://msdn.microsoft.com/en-us/library/windows/desktop/ms740121%28v=vs.85%29.aspx
    • linux : http://www.linux-kheops.com/doc/man/manfr/man-html-0.9/man2/recv.2.html

    0 讨论(0)
提交回复
热议问题