Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Does doing a connect() call affect the receive behaviour of the socket?

affect behaviour doing socket
0
Posted

Does doing a connect() call affect the receive behaviour of the socket?

0

From Richard Stevens (rstevens@noao.edu): Yes, in two ways. First, only datagrams from your “connected peer” are returned. All others arriving at your port are not delivered to you. But most importantly, a UDP socket must be connected to receive ICMP errors. Pp. 748-749 of “TCP/IP Illustrated, Volume 2” give all the gory details on why this is so. 4. How can I read ICMP errors from “connected” UDP sockets? If the target machine discards the message because there is no process reading on the requested port number, it sends an ICMP message to your machine which will cause the next system call on the socket to return ECONNREFUSED. Since delivery of ICMP messages is not guarenteed you may not recieve this notification on the first transaction. Remember that your socket must be “connected” in order to receive the ICMP errors. I’ve been told, and Alan Cox has verified that Linux will return them on “unconnected” sockets. This may cause porting problems if your application isn’t ready for it,

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123