为什么这段代码在FreeBSD上不work? (编译没问题)# Unix - 噫吁兮,危乎高哉
n*l
1 楼
下面这段代码在Linux Red Hat上run得很好, 可是在FreeBSD上run
了
之后一点反应都没有。究竟是什么问题呢?谢谢了先。
isock = socket (AF_INET, SOCK_RAW, IPROTO_ICMP);
tsock = socket (AF_INET, SOCK_RAW, IPROTO_TCP);
usock = socket (AF_INET, SOCK_RAW, IPROTO_UDP);
if (isock < 0 || tsock < 0 || usock < 0) {
exit(0);
}
while (1) {
FD_ZERO (&rfds);
FD_SET (isock, &rfds);
FD_SET (usock, &rfds);
FD_SET (tsock, &rfds);
if (select (usock + 1, &rfds, NULL, NULL, NULL) < 1) {
perror("select");
continue;
}
了
之后一点反应都没有。究竟是什么问题呢?谢谢了先。
isock = socket (AF_INET, SOCK_RAW, IPROTO_ICMP);
tsock = socket (AF_INET, SOCK_RAW, IPROTO_TCP);
usock = socket (AF_INET, SOCK_RAW, IPROTO_UDP);
if (isock < 0 || tsock < 0 || usock < 0) {
exit(0);
}
while (1) {
FD_ZERO (&rfds);
FD_SET (isock, &rfds);
FD_SET (usock, &rfds);
FD_SET (tsock, &rfds);
if (select (usock + 1, &rfds, NULL, NULL, NULL) < 1) {
perror("select");
continue;
}