is there a bug in kernel?

From: jywang
Date: Wed Nov 16 2005 - 04:02:04 EST


i program a server and a client using tcp.
the client send a string to the server, and the server send the string back
when it received it.
all is ok before i set a srr option in the socket.

the lines i used below:

char opt[7]={131, 7, 4, 192, 168, 1, 1};
if(setsockopt(socket_descriptor, SOL_IP, IP_OPTIONS, opt, 7)) printf("error
find in set options!\n");


when this lines are inserted into my program, all packets are ok except the
last packet send back
because i monitor the link using libpcap.

it seems the string back ok, but can't be received by my program. the client
is waiting and waiting and ...

why?

my client program as below:
-------------
socket_descriptor = socket(AF_INET, SOCK_STREAM, 0)) ;
char opt[7]={131, 7, 4, 192, 168, 1, 1};
if(setsockopt(socket_descriptor, SOL_IP, IP_OPTIONS, opt, 7)) printf("error
find in set options!\n");
connect(socket_descriptor, (void *)&pin, sizeof(pin)) == -1);
send(socket_descriptor, str, strlen(str)+1,0) == -1 );
recv(socket_descriptor, buf, 8192, 0) == -1) ;
---------------

my server progarm as below:
--------------
sock_descriptor = socket(AF_INET, SOCK_STREAM, 0);
bind(sock_descriptor, (struct sockaddr *)&sin, sizeof(sin)) == -1) ;
listen(sock_descriptor, 20) == -1) ;
while(1) {
temp_sock_descriptor = accept(sock_descriptor, (struct sockaddr
*)&pin, &address_size);
read(temp_sock_descriptor, buf, 16384, 0) == -1) ;
printf("\nReceived from client: %s\n", buf);
write(temp_sock_descriptor, buf, strlen(buf), 0) == -1) ;
}
--------------







-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/