Hello,
I've a problem with bering 1.2 networking that I can't imagine.
once I've install my bering 1.2 network
#
# Loopback interface.
auto lo eth0
iface lo inet loopback
#
# Option 1.2: eth0 / Fixed IP (assumed to be 1.2.3.4).
# (broadcast/gateway optional)
iface eth0 inet static
address 10.0.0.150
masklen 24
gateway 10.0.0.100
if I ping for example 66.102.11.99
# ping 66.102.11.99
PING 66.102.11.99 (66.102.11.99): 56 data bytes
64 bytes from 66.102.11.99: icmp_seq=0 ttl=247 time=44.0 ms
64 bytes from 66.102.11.99: icmp_seq=1 ttl=247 time=43.4 ms
64 bytes from 66.102.11.99: icmp_seq=2 ttl=247 time=42.8 ms
64 bytes from 66.102.11.99: icmp_seq=3 ttl=247 time=44.5 ms
--- 66.102.11.99 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 42.8/43.6/44.5 ms
but if I start my test program to connect to server I have problem.
# ./test 66.102.11.99
hostname: 66.102.11.99
gethostbyname(hostname)
/gethostbyname(hostname)
create socket
/create socket (3)
bind any port number
/bind any port number
connect to server // problem to connect
--------------------------------------------------------------
# here is the source code of the test program
--------------------------------------------------------------
int port=80;
int testServer(char *hostname)
{
int sd, rc, i;
struct sockaddr_in localAddr, servAddr;
struct hostent *h;
printf("hostname: %s\n",hostname);
printf("gethostbyname(hostname)\n");
h = gethostbyname(hostname);
printf("/gethostbyname(hostname)\n");
if(h==NULL) {
printf("unknown host \n");
return 1;
//exit(1);
}
servAddr.sin_family = h->h_addrtype;
memcpy((char *) &servAddr.sin_addr.s_addr, h->h_addr_list[0],
h->h_length);
servAddr.sin_port = htons(port);
/* create socket */
printf("create socket\n");
sd = socket(AF_INET, SOCK_STREAM, 0);
if(sd<0) {
printf("cannot open socket ");
return 1;
//exit(1);
}
printf("/create socket (%d)\n",sd);
/* bind any port number */
localAddr.sin_family = AF_INET;
localAddr.sin_addr.s_addr = htonl(INADDR_ANY);
localAddr.sin_port = htons(0);
printf("bind any port number\n");
rc = bind(sd, (struct sockaddr *) &localAddr, sizeof(localAddr));
if(rc<0) {
printf("cannot bind port TCP\n");
return 1;
//exit(1);
}
printf("/bind any port number\n");
/* connect to server */
printf("connect to server %s\n",&servAddr);
rc = connect(sd, (struct sockaddr *) &servAddr, sizeof(servAddr));
if(rc<0) {
printf("cannot connect ");
printf("error %d -> %s\n", errno, strerror(errno));
return 1;
//exit(1);
}
printf("/connect to server\n");
close(sd);
printf("Test OK! \n");
return 0;
}
int main(int argc,char *argv[])
{
if(argc==2)testServer(&argv[1][0]);
}
----------------------------------------------------
I can't imagine because with the same
configuration on my RedHat it's working fine.
./test 66.102.11.99
hostname: 66.102.11.99
gethostbyname(hostname)
/gethostbyname(hostname)
create socket
/create socket (3)
bind any port number
/bind any port number
connect to server
/connect to server
Test OK!
I'm very tankfull for any solution/idea/...
Phuoc
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
------------------------------------------------------------------------
leaf-user mailing list: [email protected]
https://lists.sourceforge.net/lists/listinfo/leaf-user
SR FAQ: http://leaf-project.org/pub/doc/docmanager/docid_1891.html