nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8b53a91
)
lib/socket: set `last_error` on failed hostname lookups
author
Alexis Laferrière
<alexis.laf@xymus.net>
Tue, 2 Jun 2015 11:33:04 +0000
(07:33 -0400)
committer
Alexis Laferrière
<alexis.laf@xymus.net>
Tue, 2 Jun 2015 15:41:48 +0000
(11:41 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
lib/socket/socket.nit
patch
|
blob
|
history
diff --git
a/lib/socket/socket.nit
b/lib/socket/socket.nit
index
4885805
..
7791159
100644
(file)
--- a/
lib/socket/socket.nit
+++ b/
lib/socket/socket.nit
@@
-71,7
+71,19
@@
class TCPStream
closed = true
return
end
- var hostname = socket.gethostbyname(host)
+
+ var hostname = sys.gethostbyname(host.to_cstring)
+ if hostname.address_is_null then
+ # Error in name lookup
+ var err = sys.h_errno
+ last_error = new IOError(err.to_s)
+
+ closed = true
+ end_reached = true
+
+ return
+ end
+
addrin = new NativeSocketAddrIn.with_hostent(hostname, port)
address = addrin.address