Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to server when no DNS available #25

Open
ducss2015 opened this issue Jul 7, 2015 · 2 comments
Open

Cannot connect to server when no DNS available #25

ducss2015 opened this issue Jul 7, 2015 · 2 comments

Comments

@ducss2015
Copy link

I encountered the following error on inet_stream_server side when I use inet_stream to connect to it with the server's IP address specified (VERBOSE set to 1)

Temporary failure in name resolution
/home/libsocket-2.4.1/C++/inetserverstream.cpp:169: inet_stream_server::accept() - could not accept new connection on stream server socket! (Success)

The reason is the getnameinfo fails when my system does not connect to the Internet. The /etc/resolv.conf on both client and server is
nameserver 127.0.0.1

I suggest to handle the case like following. (The patch has not been designed to work when _TRADITIONAL_RDNS is set, though)

diff --git a/C/inet/libinetsocket.c b/C/inet/libinetsocket.c
index 3dbb253..5b0208d 100644
--- a/C/inet/libinetsocket.c
+++ b/C/inet/libinetsocket.c
@@ -774,10 +774,12 @@ int accept_inet_stream_socket(int sfd, char* src_host, size_t src_host_len, char
           errstr = gai_strerror(retval);
           debug_write(errstr);
 # endif
-           return -1;
+      /* It is not a fatal error when the DNS is unavailable */
+      if (errno != 0)
+        return -1;
        }
 # endif

@ducss2015 ducss2015 changed the title Cannot create socket when no DNS avaiable Cannot connect to server when no DNS avaiable Jul 7, 2015
@ducss2015 ducss2015 changed the title Cannot connect to server when no DNS avaiable Cannot connect to server when no DNS available on server Jul 7, 2015
@ducss2015 ducss2015 changed the title Cannot connect to server when no DNS available on server Cannot connect to server when no DNS available Jul 7, 2015
@dermesser
Copy link
Owner

wdyt about #26?

@dermesser
Copy link
Owner

although, thinking about it -- getnameinfo() probably doesn't set errno anyway, so we could take out that condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants