UDP send behaviour after connect()

前端 未结 5 588
粉色の甜心
粉色の甜心 2021-01-05 05:31
#include   
#include   
#include   
#include   
#include   
#include 

        
5条回答
  •  猫巷女王i
    2021-01-05 05:42

    According to the linux man page for udp:

    All fatal errors will be passed to the user as an error return even when the socket is not connected. This includes asynchronous errors received from the network. You may get an error for an earlier packet that was sent on the same socket. This behaviour differs from many other BSD socket implementations which don't pass any errors unless the socket is connected. Linux's behaviour is mandated by RFC 1122.

    Specifically the RFC (4.1.3.3) states:

    UDP MUST pass to the application layer all ICMP error messages that it receives from the IP layer. Conceptually at least, this may be accomplished with an upcall to the ERROR_REPORT routine

提交回复
热议问题