Re: [Boa-devel] Help!
Brought to you by:
jnelson
From: <la...@do...> - 2006-08-26 21:31:19
|
wayne_0504 - On Fri, Aug 25, 2006 at 08:58:07AM +0800, wayne_0504 wrote: > When i was using boa,i want to get the client 'address,i used the following method: > char *str; > fd = accept(server_sock,(struct sockaddr *)&remote_addr,&remote_addrlen); > str=inet_ntoa(remote_addr.sin_addr); > but what i have got is always 0.0.32.0 which is wrong. if i erase the sentences > if (set_nonblock_fd(server_s) == -1) { > DIE("fcntl: unable to set server socket to nonblocking"); > } > which is in boa.c,then what i get just right! It sounds like you don't check the return code of accept(). If non-blocking mode is set, accept will usually return "right away" with -1 return value, and errno == EAGAIN. In that case, the remote_addr structure is not modified, so whatever trash was in there originally is retained. - Larry |