added Socket::getIfceIndex(), Socket::getIfceAddress(), etc

This commit is contained in:
2018-10-17 14:20:32 +00:00
parent 4a10c5d7cd
commit 5b529ad535
5 changed files with 316 additions and 9 deletions

View File

@ -24,6 +24,42 @@ static int test1 ()
return -1;
}
qse_printf (QSE_T("lo ifindex ===> %d\n"), s.getIfceIndex(QSE_WT("lo")));
if (s.getIfceAddress(QSE_WT("lo"), &addr) >= 0)
{
qse_char_t buf[256];
qse_printf (QSE_T("lo ifaddr ===> [%s]\n"), addr.toStrBuf(buf, QSE_COUNTOF(buf)));
}
if (s.getIfceNetmask(QSE_WT("lo"), &addr) >= 0)
{
qse_char_t buf[256];
qse_printf (QSE_T("lo netmask ===> [%s]\n"), addr.toStrBuf(buf, QSE_COUNTOF(buf)));
}
if (s.getIfceBroadcast(QSE_WT("lo"), &addr) >= 0)
{
qse_char_t buf[256];
qse_printf (QSE_T("lo broadcast ===> [%s]\n"), addr.toStrBuf(buf, QSE_COUNTOF(buf)));
}
qse_printf (QSE_T("eth0 ifindex ===> %d\n"), s.getIfceIndex(QSE_WT("eth0")));
if (s.getIfceAddress(QSE_WT("eth0"), &addr) >= 0)
{
qse_char_t buf[256];
qse_printf (QSE_T("eth0 ifaddr ===> [%s]\n"), addr.toStrBuf(buf, QSE_COUNTOF(buf)));
}
if (s.getIfceNetmask(QSE_WT("eth0"), &addr) >= 0)
{
qse_char_t buf[256];
qse_printf (QSE_T("eth0 netmask ===> [%s]\n"), addr.toStrBuf(buf, QSE_COUNTOF(buf)));
}
if (s.getIfceBroadcast(QSE_WT("eth0"), &addr) >= 0)
{
qse_char_t buf[256];
qse_printf (QSE_T("eth0 broadcast ===> [%s]\n"), addr.toStrBuf(buf, QSE_COUNTOF(buf)));
}
addr.set ("[::1]:9999");
s.connect (addr);