QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 660|回复: 0

have a problem,help,3x

[复制链接]
发表于 2003-6-3 13:06:34 | 显示全部楼层 |阅读模式
an easy program,use the raw socket:
code:
[code:1]
/*
*tcp41.c
*/
. . . . . .
new_sock=socket(AF_INET,SOCK_RAW,0);
if(new_sock<0){
printf("raw socket failure %d\n");
perror("socket:");
exit(1);
}
. . . . . .
[/code:1]
$gcc -o server tcp41.c
$./server
raw socket failure 3
socket:: Socket type not supported

why?

but if i change it to:
code:
[code:1]
new_sock=socket(AF_INET,SOCK_RAW,IPPROTO_TCP);
if(new_sock<0){
printf("raw socket failure %d\n");
perror("socket:");
exit(1);
}
[/code:1]
it correctly passed,why?
but i dont wanna fill the tcp header bu myself
hw to ?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-15 18:36 , Processed in 0.040985 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表