Networking Forums

Networking Forums > Computer Networking > Linux Networking > use IPv6 socket to get file from Apache

Reply
Thread Tools Display Modes

use IPv6 socket to get file from Apache

 
 
lgl
Guest
Posts: n/a

 
      11-19-2003, 08:34 AM
I will be very thankful if someone could give me help

I have one linux server(RedHat 9.0) running Apache 2.40.40, I configure it
with ipv6, the ipv6 address is fec0::2. another linux machine(RedHat 9.0)
run as the client with the ipv6 address of fec0::3

I use a small c program to use socket to connect to port 80 of the linux
server, send a GET http request and want to receive on the socket to get
the requested file. But it blocked when read from the socket.

The following is the client program:

#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
int main(void)
{
int sockfd;
FILE *fp;
int n;
char buf[256];
struct sockaddr_in6 serv_addr;
bzero(&serv_addr, sizeof(struct sockaddr_in6));
fp=fopen("lgl.txt", "wb");

serv_addr.sin6_family=AF_INET6;
serv_addr.sin6_port=htons(80);
inet_pton(AF_INET6, "fec0::2", &(serv_addr.sin6_addr));

sockfd=socket(PF_INET6, SOCK_STREAM, 0);
if(socket < 0) {
perror("socket");
exit(1);
}

if(connect(sockfd, (struct sockaddr *)&serv_addr, \
sizeof(struct sockaddr_in6))<0) {
perror("connect");
exit(1);
}

n=write(sockfd,"GET /lll.txt\r\n", 16);
printf("GET sent %d\n",n);
while((n=read(sockfd, buf, 256)) > 0) {
printf("recv %d:%s\n", n, buf);
fwrite(buf, n, 1, fp);
}
fclose(fp);
return 0;
}


the file 111.txt is in /var/www/html directory. I use ethereal to capture
the traffic, and found that the connection is established between fec0::2
and fec0::3 successfully, and the server received the "GET /111.txt\r\n"
request, then the server begin to send back the content of 111.txt, But
problem is that the client didn't send ACK now, so the server send the
content again and again, and the client blocked at read.

I changed the ipv6 address with ipv4 address, and all worked very well.

I write a server instead of using Apache, and the communication between
the server and the client seems very good.

Could anyone tell me the reason?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing socket file descriptors Yang Linux Networking 0 05-20-2007 04:26 AM
Binding an IPv6 address to an AF_INET socket? Roy Smith Linux Networking 5 05-13-2007 10:03 PM
atomicity / thread-safety: PF_PACKET socket and tap file descriptor Max Schmied Linux Networking 0 02-28-2007 10:31 AM
Apache 302 error from httpd.conf file, Server Down danparker276@yahoo.com Linux Networking 1 07-27-2005 01:32 AM
Apache - No listening socket... =?Utf-8?B?RWxqb2pv?= Windows Networking 0 02-22-2004 12:31 PM



1 2 3 4 5 6 7 8 9 10 11