Index: lynx/configure
diff -c lynx/configure:1.1.1.1 lynx/configure:1.2
*** lynx/configure:1.1.1.1	Thu Nov  5 13:43:15 1998
--- lynx/configure	Sat Nov  7 09:41:56 1998
***************
*** 1,5 ****
--- 1,8 ----
  #! /bin/sh
  
+ CFLAGS="-DINET6"
+ LIBS="-L/usr/local/v6/lib -linet6"
+ 
  # Guess values for system-dependent variables and create Makefiles.
  # Generated automatically using autoconf version 2.12.971230 
  # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
Index: lynx/WWW/Library/Implementation/HTFTP.c
diff -c lynx/WWW/Library/Implementation/HTFTP.c:1.1.1.1 lynx/WWW/Library/Implementation/HTFTP.c:1.2
*** lynx/WWW/Library/Implementation/HTFTP.c:1.1.1.1	Thu Nov  5 13:43:23 1998
--- lynx/WWW/Library/Implementation/HTFTP.c	Thu Jan 28 19:54:58 1999
***************
*** 999,1009 ****
  */
  PRIVATE int get_listen_socket NOARGS
  {
!     struct sockaddr_in soc_address;	/* Binary network address */
!     struct sockaddr_in* soc_in = &soc_address;
      int new_socket;			/* Will be master_socket */
  
- 
      FD_ZERO(&open_sockets);	/* Clear our record of open sockets */
      num_sockets = 0;
  
--- 999,1010 ----
  */
  PRIVATE int get_listen_socket NOARGS
  {
!     struct sockaddr_storage soc_address;	/* Binary network address */
!     struct sockaddr_in* soc_in = (struct sockaddr_in *)&soc_address;
      int new_socket;			/* Will be master_socket */
+     int af;
+     int slen;
  
      FD_ZERO(&open_sockets);	/* Clear our record of open sockets */
      num_sockets = 0;
  
***************
*** 1012,1020 ****
  	return master_socket;  /* Done already */
  #endif /* !REPEAT_LISTEN */
  
  /*  Create internet socket
  */
!     new_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  
      if (new_socket < 0)
  	return HTInetStatus("socket for master socket");
--- 1013,1030 ----
  	return master_socket;  /* Done already */
  #endif /* !REPEAT_LISTEN */
  
+     /* query address family of control connection */
+     slen = sizeof(soc_address);
+     if (getsockname(control->socket, (struct sockaddr *)&soc_address,
+ 		&slen) < 0) {
+ 	return HTInetStatus("getsockname failed");
+     }
+     af = soc_address.__ss_family;
+     memset(&soc_address, 0, sizeof(soc_address));
+ 
  /*  Create internet socket
  */
!     new_socket = socket(af, SOCK_STREAM, IPPROTO_TCP);
  
      if (new_socket < 0)
  	return HTInetStatus("socket for master socket");
***************
*** 1023,1030 ****
  
  /*  Search for a free port.
  */
!     soc_in->sin_family = AF_INET;	    /* Family = internet, host order  */
!     soc_in->sin_addr.s_addr = INADDR_ANY;   /* Any peer address */
  #ifdef POLL_PORTS
      {
  	unsigned short old_port_number = port_number;
--- 1033,1052 ----
  
  /*  Search for a free port.
  */
!     memset(&soc_address, 0, sizeof(soc_address));
!     soc_address.__ss_family = af;
!     switch (af) {
!     case AF_INET:
! 	soc_address.__ss_len = sizeof(struct sockaddr_in);
! 	break;
! #ifdef INET6
!     case AF_INET6:
! 	soc_address.__ss_len = sizeof(struct sockaddr_in6);
! 	break;
! #endif
!     default:
! 	HTInetStatus("AF");
!     }
  #ifdef POLL_PORTS
      {
  	unsigned short old_port_number = port_number;
***************
*** 1035,1047 ****
  	    if (port_number == old_port_number) {
  		return HTInetStatus("bind");
  	    }
! 	    soc_address.sin_port = htons(port_number);
  #ifdef SOCKS
  	    if (socks_flag)
  		if ((status=Rbind(new_socket,
  			(struct sockaddr*)&soc_address,
  			    /* Cast to generic sockaddr */
! 			sizeof(soc_address)
  #ifndef SHORTENED_RBIND
  			,socks_bind_remoteAddr
  #endif /* !SHORTENED_RBIND */
--- 1057,1069 ----
  	    if (port_number == old_port_number) {
  		return HTInetStatus("bind");
  	    }
! 	    soc_in->sin_port = htons(port_number);
  #ifdef SOCKS
  	    if (socks_flag)
  		if ((status=Rbind(new_socket,
  			(struct sockaddr*)&soc_address,
  			    /* Cast to generic sockaddr */
! 			soc_address.__ss_len
  #ifndef SHORTENED_RBIND
  			,socks_bind_remoteAddr
  #endif /* !SHORTENED_RBIND */
***************
*** 1052,1058 ****
  	    if ((status=bind(new_socket,
  		    (struct sockaddr*)&soc_address,
  			    /* Cast to generic sockaddr */
! 		    sizeof(soc_address))) == 0)
  		break;
  	    CTRACE(tfp, "TCP bind attempt to port %d yields %d, errno=%d\n",
  		port_number, status, SOCKET_ERRNO);
--- 1074,1080 ----
  	    if ((status=bind(new_socket,
  		    (struct sockaddr*)&soc_address,
  			    /* Cast to generic sockaddr */
! 		    soc_address.__ss_len)) == 0)
  		break;
  	    CTRACE(tfp, "TCP bind attempt to port %d yields %d, errno=%d\n",
  		port_number, status, SOCKET_ERRNO);
***************
*** 1076,1088 ****
  	CTRACE(tfp, "HTFTP: This host is %s\n",
  	    HTInetString(soc_in));
  
! 	soc_address.sin_port = 0;	/* Unspecified: please allocate */
  #ifdef SOCKS
  	if (socks_flag)
  	    status=Rbind(new_socket,
  			 (struct sockaddr*)&soc_address,
  			 /* Cast to generic sockaddr */
! 			 sizeof(soc_address)
  #ifndef SHORTENED_RBIND
  			,socks_bind_remoteAddr
  #endif /* !SHORTENED_RBIND */
--- 1098,1110 ----
  	CTRACE(tfp, "HTFTP: This host is %s\n",
  	    HTInetString(soc_in));
  
! 	soc_in->sin_port = 0;	/* Unspecified: please allocate */
  #ifdef SOCKS
  	if (socks_flag)
  	    status=Rbind(new_socket,
  			 (struct sockaddr*)&soc_address,
  			 /* Cast to generic sockaddr */
! 			 soc_address.__ss_len
  #ifndef SHORTENED_RBIND
  			,socks_bind_remoteAddr
  #endif /* !SHORTENED_RBIND */
***************
*** 1092,1098 ****
  	status=bind(new_socket,
  		    (struct sockaddr*)&soc_address,
  		    /* Cast to generic sockaddr */
! 		    sizeof(soc_address));
  	if (status<0) return HTInetStatus("bind");
  
  	address_length = sizeof(soc_address);
--- 1114,1120 ----
  	status=bind(new_socket,
  		    (struct sockaddr*)&soc_address,
  		    /* Cast to generic sockaddr */
! 		    soc_address.__ss_len);
  	if (status<0) return HTInetStatus("bind");
  
  	address_length = sizeof(soc_address);
***************
*** 1124,1130 ****
  /*	Now we must find out who we are to tell the other guy
  */
      (void)HTHostName(); 	/* Make address valid - doesn't work*/
!     sprintf(port_command, "PORT %d,%d,%d,%d,%d,%d%c%c",
  		    (int)*((unsigned char *)(&soc_in->sin_addr)+0),
  		    (int)*((unsigned char *)(&soc_in->sin_addr)+1),
  		    (int)*((unsigned char *)(&soc_in->sin_addr)+2),
--- 1146,1154 ----
  /*	Now we must find out who we are to tell the other guy
  */
      (void)HTHostName(); 	/* Make address valid - doesn't work*/
!     switch (soc_address.__ss_family) {
!     case AF_INET:
! 	sprintf(port_command, "PORT %d,%d,%d,%d,%d,%d%c%c",
  		    (int)*((unsigned char *)(&soc_in->sin_addr)+0),
  		    (int)*((unsigned char *)(&soc_in->sin_addr)+1),
  		    (int)*((unsigned char *)(&soc_in->sin_addr)+2),
***************
*** 1132,1138 ****
  		    (int)*((unsigned char *)(&soc_in->sin_port)+0),
  		    (int)*((unsigned char *)(&soc_in->sin_port)+1),
  		    CR, LF);
! 
  
  /*	Inform TCP that we will accept connections
  */
--- 1156,1179 ----
  		    (int)*((unsigned char *)(&soc_in->sin_port)+0),
  		    (int)*((unsigned char *)(&soc_in->sin_port)+1),
  		    CR, LF);
! 	break;
! #ifdef INET6
!     case AF_INET6:
!       {
! 	char hostbuf[MAXHOSTNAMELEN];
! 	char portbuf[MAXHOSTNAMELEN];
! 	getnameinfo((struct sockaddr *)&soc_address, soc_address.__ss_len,
! 	    hostbuf, sizeof(hostbuf), portbuf, sizeof(portbuf),
! 	    NI_NUMERICHOST | NI_NUMERICSERV);
! 	sprintf(port_command, "EPRT |%d|%s|%s|%c%c", 2, hostbuf, portbuf,
! 		CR, LF);
! 	break;
!       }
! #endif
!     default:
! 	sprintf(port_command, "JUNK%c%c", CR, LF);
! 	break;
!     }
  
  /*	Inform TCP that we will accept connections
  */
***************
*** 2577,2583 ****
  	if (status < 0) {
  	    NETCLOSE (control->socket);
  	    control->socket = -1;
! 	    close_master_socket ();
  	    /* HT_INTERRUPTED would fall through, if we could interrupt
  	       somehow in the middle of it, which we currently can't. */
  	    return status;
--- 2618,2625 ----
  	if (status < 0) {
  	    NETCLOSE (control->socket);
  	    control->socket = -1;
! 	    if (master_socket >= 0)
! 		(void)close_master_socket ();
  	    /* HT_INTERRUPTED would fall through, if we could interrupt
  	       somehow in the middle of it, which we currently can't. */
  	    return status;
***************
*** 2613,2639 ****
  	    int status;
  	    data_soc = status;
  
! 	    sprintf(command, "PASV%c%c", CR, LF);
  	    status = response(command);
! 	    if (status != 2) {
! 		if (status < 0)
! 		    continue;		/* retry or Bad return */
! 		return -status; 	/* bad reply */
  	    }
- 	    for (p = response_text; *p && *p != ','; p++)
- 		; /* null body */
  
! 	    while (--p > response_text && '0' <= *p && *p <= '9')
! 		; /* null body */
  
! 	   status = sscanf(p+1, "%d,%d,%d,%d,%d,%d",
! 		   &h0, &h1, &h2, &h3, &p0, &p1);
! 	   if (status < 4) {
! 	       fprintf(tfp, "HTFTP: PASV reply has no inet address!\n");
! 	       return -99;
! 	   }
! 	   passive_port = (p0<<8) + p1;
! 	   CTRACE(tfp, "HTFTP: Server is listening on port %d\n",
  			passive_port);
  
  
--- 2655,2706 ----
  	    int status;
  	    data_soc = status;
  
! 	    sprintf(command, "EPSV%c%c", CR, LF);
  	    status = response(command);
! 	    if (status < 0)	/* retry or Bad return */
! 		continue;
! 	    else if (status != 2) {
! 		sprintf(command, "PASV%c%c", CR, LF);
! 		status = response(command);
! 		if (status < 0)	/* retry or Bad return */
! 		    continue;
! 		else if (status != 2) {
! 		    return -status; 	/* bad reply */
! 		}
  	    }
  
! 	    if (strncmp(command, "PASV", 4) == 0) {
! 		for (p = response_text; *p && *p != ','; p++)
! 		    ; /* null body */
  
! 		while (--p > response_text && '0' <= *p && *p <= '9')
! 		    ; /* null body */
! 
! 	       status = sscanf(p+1, "%d,%d,%d,%d,%d,%d",
! 		       &h0, &h1, &h2, &h3, &p0, &p1);
! 	       if (status < 4) {
! 		   fprintf(tfp, "HTFTP: PASV reply has no inet address!\n");
! 		   return -99;
! 	       }
! 	       passive_port = (p0<<8) + p1;
! 	    } else if (strncmp(command, "EPSV", 4) == 0) {
! 		char ch;
! 		/*
! 		 * EPSV |||port|
! 		 */
! 		for (p = response_text; *p && !isspace(*p); p++)
! 		    ; /* null body */
! 		for (p = response_text; *p && isspace(*p); p++)
! 		    ; /* null body */
! 		status = sscanf(p+1, "%c%c%c%d%c",
! 		       &h0, &h1, &h2, &p0, &h3);
! 		if (status != 5) {
! 		    fprintf(tfp, "HTFTP: EPSV reply has invalid format!\n");
! 		    return -99;
! 		}
! 		passive_port = p0;
! 	    }
! 	    CTRACE(tfp, "HTFTP: Server is listening on port %d\n",
  			passive_port);
  
  
***************
*** 3145,3151 ****
  /*	Wait for the connection
  */
      {
! 	struct sockaddr_in soc_address;
  	int	soc_addrlen=sizeof(soc_address);
  #ifdef SOCKS
  	if (socks_flag)
--- 3212,3218 ----
  /*	Wait for the connection
  */
      {
! 	struct sockaddr_storage soc_address;
  	int	soc_addrlen=sizeof(soc_address);
  #ifdef SOCKS
  	if (socks_flag)
Index: lynx/WWW/Library/Implementation/HTTCP.c
diff -c lynx/WWW/Library/Implementation/HTTCP.c:1.1.1.1 lynx/WWW/Library/Implementation/HTTCP.c:1.7
*** lynx/WWW/Library/Implementation/HTTCP.c:1.1.1.1	Thu Nov  5 13:43:23 1998
--- lynx/WWW/Library/Implementation/HTTCP.c	Thu May 20 16:28:14 1999
***************
*** 299,311 ****
  PUBLIC CONST char * HTInetString ARGS1(
  	SockA*, 	soc_in)
  {
!     static char string[16];
!     sprintf(string, "%d.%d.%d.%d",
! 	    (int)*((unsigned char *)(&soc_in->sin_addr)+0),
! 	    (int)*((unsigned char *)(&soc_in->sin_addr)+1),
! 	    (int)*((unsigned char *)(&soc_in->sin_addr)+2),
! 	    (int)*((unsigned char *)(&soc_in->sin_addr)+3));
!     return string;
  }
  #endif /* !DECNET */
  
--- 299,308 ----
  PUBLIC CONST char * HTInetString ARGS1(
  	SockA*, 	soc_in)
  {
!     static char hostbuf[MAXHOSTNAMELEN];
!     getnameinfo((struct sockaddr *)soc_in, soc_in->sin_len,
! 	    hostbuf, sizeof(hostbuf), NULL, 0, NI_NUMERICHOST);
!     return hostbuf;
  }
  #endif /* !DECNET */
  
***************
*** 361,367 ****
      /*
      **	Parse port number if present.
      */
!     if ((port = strchr(host, ':')) != NULL) {
  	*port++ = 0;		/* Chop off port */
  	if (port[0] >= '0' && port[0] <= '9') {
  #ifdef unix
--- 358,364 ----
      /*
      **	Parse port number if present.
      */
!     if ((port = strrchr(host, ':')) != NULL) {
  	*port++ = 0;		/* Chop off port */
  	if (port[0] >= '0' && port[0] <= '9') {
  #ifdef unix
***************
*** 396,401 ****
--- 393,404 ----
  		soc_in->sdn_objnum, host);
  #else  /* parse Internet host: */
  
+     /* [host] case */
+     if (host[0] == '[' && host[strlen(host) - 1] == ']') {
+ 	host[strlen(host) - 1] = '\0';
+ 	host++;
+     }
+ 
      if (*host >= '0' && *host <= '9') {   /* Test for numeric node address: */
  	char *strptr = host;
  	while (*strptr) {
***************
*** 414,420 ****
      /*
      **	Parse host number if present.
      */
!     if (dotcount_ip == 3) {   /* Numeric node address: */
  
  #ifdef DJGPP
  	soc_in->sin_addr.s_addr = htonl(aton(host));
--- 417,428 ----
      /*
      **	Parse host number if present.
      */
! #ifndef INET6
!     if (dotcount_ip == 3)   /* Numeric node address: */
! #else
!     if (0)	/* numeric node address is handled by getaddrinfo() */
! #endif
!     {
  
  #ifdef DJGPP
  	soc_in->sin_addr.s_addr = htonl(aton(host));
***************
*** 680,691 ****
  	memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length);
  #else /* !NSL_FORK, !DJGPP, !_WINDOWS_NSL: */
  	{
! 	    struct hostent  *phost;
! 	    phost = gethostbyname(host);	/* See netdb.h */
  #ifdef MVS
! 	    CTRACE(tfp, "HTParseInet: gethostbyname() returned %d\n", phost);
  #endif /* MVS */
! 	    if (!phost) goto failed;
  #if defined(VMS) && defined(CMU_TCP)
  	    /*
  	    **  In LIBCMU, phost->h_length contains not the length of one address
--- 688,708 ----
  	memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length);
  #else /* !NSL_FORK, !DJGPP, !_WINDOWS_NSL: */
  	{
! 	    struct addrinfo hints, *res;
! 	    int error;
! 
! 	    memset(&hints, 0, sizeof(hints));
! 	    hints.ai_family = PF_UNSPEC;
! 	    error = getaddrinfo(host, port, &hints, &res);
! 
  #ifdef MVS
! 	    CTRACE(tfp, "HTParseInet: getaddrinfo() returned %p\n", res);
  #endif /* MVS */
! 	    if (error || !res) {
! 		CTRACE(tfp, "HTParseInet: getaddrinfo(%s): %s\n", host,
! 			gai_strerror(error));
! 		goto failed;
! 	    }
  #if defined(VMS) && defined(CMU_TCP)
  	    /*
  	    **  In LIBCMU, phost->h_length contains not the length of one address
***************
*** 695,704 ****
  	    **  longer supported, and CMU users are encouraged to obtain and use
  	    **  SOCKETSHR/NETLIB instead. - S. Bjorndahl
  	    */
! 	    memcpy((void *)&soc_in->sin_addr, phost->h_addr, 4);
  #else
! 	    memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length);
  #endif /* VMS && CMU_TCP */
  	}
  #endif /* !NSL_FORK, !DJGPP, !_WINDOWS_NSL */
  #endif /* !NSL_FORK, !DJGPP */
--- 712,729 ----
  	    **  longer supported, and CMU users are encouraged to obtain and use
  	    **  SOCKETSHR/NETLIB instead. - S. Bjorndahl
  	    */
! 	    if (res->ai_family == AF_INET) {
! 		memcpy((void *)&soc_in->sin_addr,
! 		    &((struct sockaddr_in *)res->ai_addr)->sin_addr, 4);
! 	    } else {
! 		CTRACE(tfp, "HTParseInet: unsupported address family %d\n",
! 			res->ai_family);
! 		goto failed;
! 	    }
  #else
! 	    memcpy((void *)soc_in, res->ai_addr, res->ai_addrlen);
  #endif /* VMS && CMU_TCP */
+ 	    freeaddrinfo(res);
  	}
  #endif /* !NSL_FORK, !DJGPP, !_WINDOWS_NSL */
  #endif /* !NSL_FORK, !DJGPP */
***************
*** 752,758 ****
      char *domain_name;			/* The name of this host domain */
  #endif /* UCX */
  #ifdef NEED_HOST_ADDRESS		/* no -- needs name server! */
!     struct hostent * phost;		/* Pointer to host -- See netdb.h */
  #endif /* NEED_HOST_ADDRESS */
      int namelength = sizeof(name);
  
--- 777,784 ----
      char *domain_name;			/* The name of this host domain */
  #endif /* UCX */
  #ifdef NEED_HOST_ADDRESS		/* no -- needs name server! */
!     struct addrinfo hints, *res;
!     int error;
  #endif /* NEED_HOST_ADDRESS */
      int namelength = sizeof(name);
  
***************
*** 778,791 ****
  
  #ifndef DECNET	/* Decnet ain't got no damn name server 8#OO */
  #ifdef NEED_HOST_ADDRESS		/* no -- needs name server! */
!     phost = gethostbyname(name);	/* See netdb.h */
!     if (!OK_HOST(phost)) {
! 	CTRACE(tfp, "TCP: Can't find my own internet node address for `%s'!!\n",
! 		    name);
  	return;  /* Fail! */
      }
!     StrAllocCopy(hostname, phost->h_name);
!     memcpy(&HTHostAddress, &phost->h_addr, phost->h_length);
      CTRACE(tfp, "     Name server says that I am `%s' = %s\n",
  		hostname, HTInetString(&HTHostAddress));
  #endif /* NEED_HOST_ADDRESS */
--- 804,822 ----
  
  #ifndef DECNET	/* Decnet ain't got no damn name server 8#OO */
  #ifdef NEED_HOST_ADDRESS		/* no -- needs name server! */
!     memset(&hints, 0, sizeof(hints));
!     hints.ai_family = PF_UNSPEC;
!     hints.ai_flags = AI_CANONNAME;
!     error = getaddrinfo(name, NULL, &hints, &res);
!     if (error || !res || !res->ai_canonname) {
! 	CTRACE(tfp, "TCP: %s: `%s'\n", gai_strerror(error), name);
! 	if (res)
! 	    freeaddrinfo(res);
  	return;  /* Fail! */
      }
!     StrAllocCopy(hostname, res->ai_canonname);
!     memcpy(&HTHostAddress, res->ai_addr, res->ai_addrlen);
!     freeaddrinfo(res);
      CTRACE(tfp, "     Name server says that I am `%s' = %s\n",
  		hostname, HTInetString(&HTHostAddress));
  #endif /* NEED_HOST_ADDRESS */
***************
*** 810,817 ****
  	int,		default_port,
  	int *,		s)
  {
!     struct sockaddr_in soc_address;
!     struct sockaddr_in *soc_in = &soc_address;
      int status;
      char *line = NULL;
      char *p1 = NULL;
--- 841,847 ----
  	int,		default_port,
  	int *,		s)
  {
!     struct sockaddr_storage soc_address;
      int status;
      char *line = NULL;
      char *p1 = NULL;
***************
*** 821,829 ****
      /*
      **	Set up defaults.
      */
!     memset(soc_in, 0, sizeof(*soc_in));
!     soc_in->sin_family = AF_INET;
!     soc_in->sin_port = htons(default_port);
  
      /*
      **	Get node name and optional port number.
--- 851,857 ----
      /*
      **	Set up defaults.
      */
!     memset(&soc_address, 0, sizeof(soc_address));
  
      /*
      **	Get node name and optional port number.
***************
*** 844,850 ****
  	outofmem(__FILE__, "HTDoConnect");
      sprintf (line, "Looking up %s.", host);
      _HTProgress (line);
!     status = HTParseInet(soc_in, host);
      if (status) {
  	if (status != HT_INTERRUPTED) {
  	    sprintf (line, "Unable to locate remote host %s.", host);
--- 872,878 ----
  	outofmem(__FILE__, "HTDoConnect");
      sprintf (line, "Looking up %s.", host);
      _HTProgress (line);
!     status = HTParseInet((struct sockaddr_in *)&soc_address, host);
      if (status) {
  	if (status != HT_INTERRUPTED) {
  	    sprintf (line, "Unable to locate remote host %s.", host);
***************
*** 855,860 ****
--- 883,898 ----
  	FREE(line);
  	return status;
      }
+     switch (soc_address.__ss_family) {
+     case AF_INET:
+ 	((struct sockaddr_in *)&soc_address)->sin_port = htons(default_port);
+ 	break;
+ #ifdef INET6
+     case AF_INET6:
+ 	((struct sockaddr_in6 *)&soc_address)->sin6_port = htons(default_port);
+ 	break;
+ #endif
+     }
  
      sprintf (line, "Making %s connection to %s.", protocol, host);
      _HTProgress (line);
***************
*** 863,871 ****
      /*
      **	Now, let's get a socket set up from the server for the data.
      */
!     *s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
      if (*s == -1) {
  	HTAlert("socket failed.");
  	FREE(line);
  	return HT_NO_DATA;
      }
--- 901,919 ----
      /*
      **	Now, let's get a socket set up from the server for the data.
      */
!     *s = socket(soc_address.__ss_family, SOCK_STREAM, IPPROTO_TCP);
      if (*s == -1) {
+ #if 1
+ 	char hostbuf[1024], portbuf[1024];
+ 	getnameinfo((struct sockaddr *)&soc_address, soc_address.__ss_len,
+ 		hostbuf, sizeof(hostbuf), portbuf, sizeof(portbuf),
+ 		NI_NUMERICHOST|NI_NUMERICSERV);
+ 	sprintf (line, "socket failed: family %d addr %s port %s.",
+ 		soc_address.__ss_family, hostbuf, portbuf);
+ 	_HTProgress (line);
+ #else
  	HTAlert("socket failed.");
+ #endif
  	FREE(line);
  	return HT_NO_DATA;
      }
***************
*** 898,911 ****
  #ifdef SOCKS
      if (socks_flag) {
  	status = Rconnect(*s, (struct sockaddr*)&soc_address,
! 			  sizeof(soc_address));
  	/*
  	**  For long Rbind.
  	*/
  	socks_bind_remoteAddr = soc_address.sin_addr.s_addr;
      } else
  #endif /* SOCKS */
!     status = connect(*s, (struct sockaddr*)&soc_address, sizeof(soc_address));
  #ifndef DJGPP
      /*
      **	According to the Sun man page for connect:
--- 946,959 ----
  #ifdef SOCKS
      if (socks_flag) {
  	status = Rconnect(*s, (struct sockaddr*)&soc_address,
! 			  soc_address.__ss_len);
  	/*
  	**  For long Rbind.
  	*/
  	socks_bind_remoteAddr = soc_address.sin_addr.s_addr;
      } else
  #endif /* SOCKS */
!     status = connect(*s, (struct sockaddr*)&soc_address, soc_address.__ss_len);
  #ifndef DJGPP
      /*
      **	According to the Sun man page for connect:
***************
*** 992,998 ****
  		} else {
  #endif /* SOCKS */
  		status = connect(*s, (struct sockaddr*)&soc_address,
! 				 sizeof(soc_address));
  #ifdef UCX
  		/*
  		**  A UCX feature: Instead of returning EISCONN
--- 1040,1046 ----
  		} else {
  #endif /* SOCKS */
  		status = connect(*s, (struct sockaddr*)&soc_address,
! 				 soc_address.__ss_len);
  #ifdef UCX
  		/*
  		**  A UCX feature: Instead of returning EISCONN
***************
*** 1035,1041 ****
  		**  errno = 18242 instead the EALREADY or EISCONN.
  		*/
  		status = connect(*s, (struct sockaddr*)&soc_address,
! 				 sizeof(soc_address));
  		if ((status < 0) &&
  		    (SOCKET_ERRNO != EALREADY && SOCKET_ERRNO != EAGAIN) &&
  #ifdef UCX
--- 1083,1089 ----
  		**  errno = 18242 instead the EALREADY or EISCONN.
  		*/
  		status = connect(*s, (struct sockaddr*)&soc_address,
! 				soc_address.__ss_len);
  		if ((status < 0) &&
  		    (SOCKET_ERRNO != EALREADY && SOCKET_ERRNO != EAGAIN) &&
  #ifdef UCX
Index: lynx/src/LYUtils.c
diff -c lynx/src/LYUtils.c:1.1.1.1 lynx/src/LYUtils.c:1.2
*** lynx/src/LYUtils.c:1.1.1.1	Thu Nov  5 13:43:19 1998
--- lynx/src/LYUtils.c	Sat Nov  7 09:42:00 1998
***************
*** 4148,4154 ****
      char *Path = NULL;
      char *Fragment = NULL;
      int hoststat;
!     SockA sock;
      BOOLEAN GotHost = FALSE;
      BOOLEAN Startup = (helpfilepath == NULL);
  
--- 4148,4156 ----
      char *Path = NULL;
      char *Fragment = NULL;
      int hoststat;
!     struct sockaddr_storage sock;
!     struct sockaddr_in *sin = (struct sockaddr_in *)&sock;
!     struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sock;
      BOOLEAN GotHost = FALSE;
      BOOLEAN Startup = (helpfilepath == NULL);
  
***************
*** 4223,4230 ****
  	fprintf(stdout, "Looking up '%s' first.\n", host);
      }
  #ifndef DJGPP
!     sock.sin_port = htons(80);
!     if ((hoststat = HTParseInet(&sock, host)) == 0)
  #else
      if (resolve(host) != 0)
  #endif /* DJGPP */
--- 4225,4232 ----
  	fprintf(stdout, "Looking up '%s' first.\n", host);
      }
  #ifndef DJGPP
!     memset(&sock, 0, sizeof(sock));
!     if ((hoststat = HTParseInet(sin, host)) == 0)
  #else
      if (resolve(host) != 0)
  #endif /* DJGPP */
***************
*** 4264,4269 ****
--- 4266,4274 ----
  	FREE(MsgStr);
  	return FALSE;
      }
+ #ifndef DJGPP
+     sin->sin_port = htons(80);
+ #endif
  
      /*
       *	Set the first prefix, making it a zero-length string
***************
*** 4345,4352 ****
  		fprintf(stdout, "Looking up '%s', guessing...\n", host);
  	    }
  #ifndef DJGPP
! 	    sock.sin_port = htons(80);
! 	    GotHost = ((hoststat = HTParseInet(&sock, host)) == 0);
  #else
  	    GotHost = (resolve(host) != 0);
  #endif /* DJGPP */
--- 4350,4358 ----
  		fprintf(stdout, "Looking up '%s', guessing...\n", host);
  	    }
  #ifndef DJGPP
! 	    hoststat = HTParseInet((struct sockaddr_in *)&sock, host);
! 	    sin->sin_port = htons(80);
! 	    GotHost = (hoststat == 0);
  #else
  	    GotHost = (resolve(host) != 0);
  #endif /* DJGPP */
