lkml.org 
[lkml]   [2005]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subjectis there a bug in kernel?
Date
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-11-16 10:04    [from the cache]
©2003-2011 Jasper Spaans