From 7b7b05bfc3f45ea5762263fdaaf9a9ac2f31b3ac Mon Sep 17 00:00:00 2001 From: jjgarcia Date: Fri, 25 Oct 2002 09:33:17 +0000 Subject: [PATCH] Build a the internet address properly. One cannot just pass the unsigned long on architectures with "wrong" endianness. --- src/c/tcp.d | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/c/tcp.d b/src/c/tcp.d index 987d14377..1e4df0bc7 100644 --- a/src/c/tcp.d +++ b/src/c/tcp.d @@ -320,6 +320,7 @@ make_stream(cl_object host, int fd, enum smmode smm) @(defun si::lookup-host-entry (host_or_address) struct hostent *he; unsigned long l; + unsigned char address[4]; cl_object name, aliases, addresses; int i; @ @@ -330,11 +331,14 @@ make_stream(cl_object host, int fd, enum smmode smm) break; case t_fixnum: l = fix(host_or_address); - he = gethostbyaddr(&l, 4, AF_INET); - break; + goto addr; case t_bignum: l = big_to_ulong(host_or_address); - he = gethostbyaddr(&l, 4, AF_INET); + addr: address[0] = l & 0xFF; + address[1] = (l >> 8) & 0xFF; + address[2] = (l >> 16) & 0xFF; + address[3] = (l >> 24) & 0xFF; + he = gethostbyaddr(&address, 4, AF_INET); break; default: FEerror("LOOKUP-HOST-ENTRY: Number or string expected, got ~S",