这是不能实现的程序: #include <sys/types.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
int
main(void)
{
int fd,n;
int res;
char buff[4];
if((fd=socket(AF_INET,SOCK_STREAM,0)) <0) {
perror("sock error");
exit(1);
}
if((n=ioctl(fd,FIONREAD,&res))<0) {
perror("ioctl error");
exit(1);
}
/* do some tink */
} 用netfilter很容易搞定,呵呵 我bc哦,这ioctl和buffer有什么关系? 我只知道套接字的buffer的大小是可以用getsocketopt和setsocketopt来进行获取和设置的 8知道u说的是这个意思么? 用ioctl()取得socket的缓冲区在中文版的<unix network programming 1>>说有。P176 ioctl(sock,FIONREAD,&to_read);
buff=(char *)malloc(to_read);
get=read(sock,buff,to_read); |