|
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 ? |
|