[comp.unix.sysv386] Roell's X11R4 server & TCP Problem Found/Solved?

paul@sdgsun.uucp (Paul Emerson) (12/06/90)

  Pim Zandbergen says:

  When I start the server, "Getting interface configuration: invalid argument"
  is displayed, just before it goes to graphics mode.
  This message turns out to come from mit/server/os/4.2bsd/access.c,
  which does an ioctl(SIOCGIFCONF) that fails.

Well I got the same problem.  I am running 386/ix 2.0.2 with TCP 1.2.
I started to look for information on SIOCGIFCONF ioctl in the TCP manual,
but no such luck.  Ok, so I wrote a little quick and dirty program that
that opens a tcp socket at port 6000 (X.server), then tried the ioctl
call.  Well my program failed with the same error as the server was 
giving.  The first thought in my head is, "another fine mess Interactive".
Well I sent this program over to a Sun 3/160 compiled it and it ran
OK.  My second thought was, "Yeah it's Interactive".  BUT then it
compiled it with gcc 1.37.1(no gas) (same as I am using on the 386) on 
the Sun and it doesn't work.  Using cc on the 386, the program work!  
So it seems that gcc is the problem here.  I haven't spent any time 
trying to figure out why.  I hope someone more familar with gcc 
could tell me. 

Here's the quick and dirty test program: (no flames please)
 
---------------------------- Cut Here ---------------------------------
#include <sys/types.h>
#include <sys/stream.h>
#ifndef sun 
#include <sys/sioctl.h>
#endif
#include <errno.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <net/if.h>

main(argc,argv)
int argc;
char *argv[];
{
struct ifconf ifc;
int fd;
char buffer[2048];


	if ((fd = open_tcp_socket()) < 0)
   {
   perror("TCP OPEN FAILS");
   exit(1);
   }
ifc.ifc_ifcu.ifcu_buf=buffer;
ifc.ifc_len = 2048; 

if (ioctl (fd,SIOCGIFCONF, (char *)&ifc) < 0)
   {
   perror("Getting interace configuration");
   close(fd);
   shutdown(fd,0);
   exit(1);
   }
printf("got it ok\n");
close(fd);
shutdown(fd,0);
}

static int
open_tcp_socket()
{
struct sockaddr_in insock;
int request;
int retry;

	if ((request = socket(AF_INET, SOCK_STREAM, 0)) < 0)
	   {
	   perror("Creating TCP socket");
	   return (-1);
	   }
	memset(&insock,'\0',sizeof(insock));
	insock.sin_family = AF_INET;
	insock.sin_port = htons(6000);
	insock.sin_addr.s_addr=htonl(INADDR_ANY);
	retry = 20;
	while (bind(request,  (struct sockaddr *) &insock, sizeof (insock)))
	      {
	      if (--retry == 0)
	         {
	         perror("Binding TCP Socket");	
	         close(request);
	    	 return (-1);
	         }
		  sleep(10); 
	      }

	if (listen (request, 5))
	   {
	   perror("TCP Listening");
	   close(request);
	   return(1);
	   }
return(request);
}
-- 
Paul J. Emerson                           SDG Division of SAIC 
Senior Technical Manager                  450 Lakemont Ave.
UUCP:     uunet|tarpit!sdgsun!paul        Winter Park, FL 32792
Internet: sdgsun!paul@bikini.cis.ufl.edu  (407) 657-1300

pim@cti-software.nl (Pim Zandbergen) (12/07/90)

paul@sdgsun.uucp (Paul Emerson) writes:



>  Pim Zandbergen says:

>  When I start the server, "Getting interface configuration: invalid argument"
>  is displayed, just before it goes to graphics mode.
>  This message turns out to come from mit/server/os/4.2bsd/access.c,
>  which does an ioctl(SIOCGIFCONF) that fails.

>Well I got the same problem.  I am running 386/ix 2.0.2 with TCP 1.2.
>I started to look for information on SIOCGIFCONF ioctl in the TCP manual,
>but no such luck.  Ok, so I wrote a little quick and dirty program that

Thanks to Jan Herder from Sweden, who suggested to use gcc -traditional,
this problem has been solved. But TCP/IP connections still don't
work for me. I even recompiled everything (except the server,
which is written in ANSI C) using this flag, without succes.
-- 
Pim Zandbergen                          domain : pim@cti-software.nl
CTI Software BV                         uucp   : uunet!mcsun!hp4nl!ctisbv!pim
Laan Copes van Cattenburch 70           phone  : +31 70 3542302
2585 GD The Hague, The Netherlands      fax    : +31 70 3512837

roell@informatik.tu-muenchen.dbp.de (Thomas Roell) (12/07/90)

>the Sun and it doesn't work.  Using cc on the 386, the program work!  
>So it seems that gcc is the problem here.  I haven't spent any time 
>trying to figure out why.  I hope someone more familar with gcc 
>could tell me. 

GCC has definitively problems with handling structs as paramters to functions.
But since GCC produces much faster code, I decided to use GCC as standard for
this server. Perhaps everyone should report me, what files cann't be compiled
with gcc the right way, so I can make special Imake-rules for them. 

- Thomas
--
_______________________________________________________________________________
Mail:                    Thomas Roell (c/o Daniel Hernandez)
                         Inst. f. Informatik / Technische Universitaet M"unchen
                         Arcisstr. 21 / 8000 Munich 2 / Fed.Rep. of Germany
E-Mail (domain):	 roell@lan.informatik.tu-muenchen.dbp.de
UUCP (when above fails): roell@tumult.{uucp | informatik.tu-muenchen.de}
-------------------------------------------------------------------------------

james@bigtex.cactus.org (James Van Artsdalen) (12/08/90)

In <5952@tuminfo1.lan.informatik.tu-muenchen.dbp.de>,
	roell@informatik.tu-muenchen.dbp.de (Thomas Roell) wrote:

> GCC has definitively problems with handling structs as paramters to
> functions.

I am not aware of any open bug reports in gcc on i386 structure
passing.  If you have a bug, and you haven't forgotten to run
fixincludes or use -fpcc-struct-return, please report the bug to FSF,
or send mail to me, or something.  Bugs do get fixed...  but only if
reported.
-- 
James R. Van Artsdalen          james@bigtex.cactus.org   "Live Free or Die"
Dell Computer Co    9505 Arboretum Blvd Austin TX 78759         512-338-8789

tim@delluk.uucp (Tim Wright) (12/10/90)

In <5952@tuminfo1.lan.informatik.tu-muenchen.dbp.de> roell@informatik.tu-muenchen.dbp.de (Thomas Roell) writes:

>>the Sun and it doesn't work.  Using cc on the 386, the program work!  
>>So it seems that gcc is the problem here.  I haven't spent any time 
>>trying to figure out why.  I hope someone more familar with gcc 
>>could tell me. 

>GCC has definitively problems with handling structs as paramters to functions.

Surely there's no problem if you use gcc -fpcc-struct-return ????
--
Tim Wright, Dell Computer Corp. (UK) | Email address
Bracknell, Berkshire, RG12 1RW       | Domain: tim@dell.co.uk
Tel: +44-344-860456                  | Uucp: ...!ukc!delluk!tim
"What's the problem? You've got an IQ of six thousand, haven't you?"