主题 : 把mini2440当客户端出错:gethostbyaddr:no such file or directory   急?? 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 5164
精华: 0
发帖: 37
金钱: 320 两
威望: 280 点
综合积分: 74 分
注册时间: 2009-04-12
最后登录: 2011-06-07
楼主  发表于: 2009-05-22 10:15

 把mini2440当客户端出错:gethostbyaddr:no such file or directory   急??

我编了个客户——服务器端程序,若将mini2440做server,主机(虚拟机)做client运行没问题,相互能通信;而换过来,将主机做server,mini2440做client,则在client端提示gethostbyaddr:no such file or directory
可是我在mini2440里的/etc/hosts文件里已经加入了主机的IP与主机名的映射,且dns也没问题,为什么还出现这种错误呢??请教高手,多谢!
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2009-05-22 10:43

 Re:把mini2440当客户端出错:gethostbyaddr:no such file or directory  急??

交叉编译一个strace工具,在开发板上运行strace + 你的程序,把输出贴出来。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 5164
精华: 0
发帖: 37
金钱: 320 两
威望: 280 点
综合积分: 74 分
注册时间: 2009-04-12
最后登录: 2011-06-07
2楼  发表于: 2009-05-22 11:48
strace结果如下:
execve("./client_a", ["./client_a", "192.168.1.102"], [/* 9 vars */]) = 0
uname({sys="Linux", node="FriendlyARM", ...}) = 0
brk(0)                                  = 0x12000
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("/lib/v4l/half/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/v4l/half", 0xbec032ec)     = -1 ENOENT (No such file or directory)
open("/lib/v4l/libc.so.6", O_RDONLY)    = -1 ENOENT (No such file or directory)
stat64("/lib/v4l", 0xbec032ec)          = -1 ENOENT (No such file or directory)
open("/lib/half/libc.so.6", O_RDONLY)   = -1 ENOENT (No such file or directory)
stat64("/lib/half", 0xbec032ec)         = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\270p\1\000"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=1407357, ...}) = 0
old_mmap(NULL, 1285720, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40022000
mprotect(0x4014e000, 56920, PROT_NONE)  = 0
old_mmap(0x40152000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x128000) = 0x40152000
old_mmap(0x4015a000, 7768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4015a000
close(3)                                = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40019000
brk(0)                                  = 0x12000
brk(0x13000)                            = 0x13000
brk(0)                                  = 0x13000
socket(PF_FILE, SOCK_STREAM, 0)         = 3
connect(3, {sa_family=AF_FILE, path="/var/run/.nscd_socket"}, 112) = -1 ENOENT (No such file or directory)
close(3)                                = 0
open("/etc/nsswitch.conf", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/lib/libnss_dns.so.2", O_RDONLY)  = 3
read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\234\16\0"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=16958, ...}) = 0
old_mmap(NULL, 45056, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x4015c000
mprotect(0x4015f000, 32768, PROT_NONE)  = 0
old_mmap(0x40164000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x40164000
close(3)                                = 0
open("/lib/libresolv.so.2", O_RDONLY)   = 3
read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0x)\0\0004"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=72883, ...}) = 0
old_mmap(NULL, 106172, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40167000
mprotect(0x40176000, 44732, PROT_NONE)  = 0
old_mmap(0x40177000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x8000) = 0x40177000
old_mmap(0x4017f000, 7868, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4017f000
close(3)                                = 0
gettimeofday({1223943039, 303333}, NULL) = 0
getpid()                                = 380
open("/etc/resolv.conf", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=25, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001a000
read(3, "nameserver 202.117.112.3\n", 4096) = 25
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x4001a000, 4096)                = 0
uname({sys="Linux", node="FriendlyARM", ...}) = 0
open("/etc/host.conf", O_RDONLY)        = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=17, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001a000
read(3, "order hosts,bind\n", 4096)     = 17
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x4001a000, 4096)                = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("202.117.112.3")}, 28) = 0
send(3, "B\347\1\0\0\1\0\0\0\0\0\0\003102\0011\003168\003192\7i"..., 44, 0) = 44
gettimeofday({1223943039, 338310}, NULL) = 0
poll([{fd=3, events=POLLIN, revents=POLLIN}], 1, 5000) = 1
ioctl(3, FIONREAD, [121])               = 0
recvfrom(3, "B\347\201\203\0\1\0\0\0\1\0\0\003102\0011\003168\00319"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("202.117.112.3")}, [16]) = 121
close(3)                                = 0
dup(2)                                  = 3
fcntl64(3, F_GETFL)                     = 0x2 (flags O_RDWR)
fstat64(3, {st_mode=S_IFCHR|0600, st_rdev=makedev(5, 1), ...}) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 opost isig icanon echo ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001a000
_llseek(3, 0, 0xbec03490, SEEK_CUR)     = -1 ESPIPE (Illegal seek)
write(3, "gethostbyaddr: No such file or d"..., 41) = 41
close(3)                                = 0
munmap(0x4001a000, 4096)                = 0
io_submit(0x1, 0x40157060, 0 <unfinished ... exit status 1>

*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
3楼  发表于: 2009-05-22 12:00

 Re:把mini2440当客户端出错:gethostbyaddr:no such file or directory  急??

connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("202.117.112.3")}, 28) = 0
send(3, "B\347\1\0\0\1\0\0\0\0\0\0\003102\0011\003168\003192\7i"..., 44, 0) = 44
gettimeofday({1223943039, 338310}, NULL) = 0
poll([{fd=3, events=POLLIN, revents=POLLIN}], 1, 5000) = 1
ioctl(3, FIONREAD, [121])               = 0
recvfrom(3, "B\347\201\203\0\1\0\0\0\1\0\0\003102\0011\003168\00319"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("202.117.112.3")}, [16]) = 121

看起来并不是哪个文件不存在,而是你所连接的DNS服务器202.117.112.3返回的东西直接让gethostbyaddr认为出错了
[ 此帖被kasim在2009-05-22 12:11重新编辑 ]
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
4楼  发表于: 2009-05-22 12:05

 Re:把mini2440当客户端出错:gethostbyaddr:no such file or directory  急??

从strace的输出看,并没有去读/etc/hosts.conf
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."