Reputation: 7422
Hi I'm trying to reproduce addressFamily Exception
std::auto_ptr<UdpSocket> s_StatusSocket;
//.......
//.......
try
{
s_StatusSocket->send(&f.addr, reqBuf, reqLen);
}
catch (const SystemException& se)
{
string exceptionMessage=se.what();
if(exceptionMessage.find("ddress family"))
{
//Finally THrown
}
}
for that i'm using iptables to block the IP's,
iptables -A INPUT -s 10.10.0.1 -j DROP
service iptables save
Doing so there is no exception is thrown on the send block, do let me know how to reproduce address family not supported in Linux
Upvotes: 1
Views: 295
Reputation: 9696
Compile a kernel without IPv6. Or use an otherwise unsupported address family.
You can't use iptables - that's got absolutely nothing to do with which address families are supported. You need to actually pass in an address that isn't supported when you call socket(2)
. Note also that if you read the man page for send()
, you'll observe it doesn't return EAFNOSUPPORT
! You've misread the documentation - the EAFNOSUPPORT
error is returned by socket(2)
, connect(2)
, and socketpair(2)
.
Upvotes: 1
Reputation: 7271
The UDP protocol offers no guarantees about delivery of packets. There is no confirmation of receipt by the intended recipient. As far as the UdpSocket
is concerned it has sent the packets. It is not aware that IPTables is throwing them away.
If you want to know whether data has made it to the intended recipient you should use TCP.
Upvotes: 0