[comp.unix.i386] HELP : problems with t_connect on CTIX 3.2

jcc@adesign.uucp (Jean Christophe) (07/23/90)

Hello folks,

HELP : I'M STUCK!

I need help about TLI programming on CTIX 3.2 (Convergent Technologies's
SYSV 3.2 for 386 boxes) :

Here is my problem :

The TLI library function t_connect fails systematically on the /dev/tcp device!
It returns with t_errno = 8 (System Error) and errno = 22 (Invalid Argument).
I have tracked down this error as deep as I could and I discovered that it
comes from the getmsg system call. The control structure that getmsg returns
tells what error occured. That means the system call was OK, but the driver
couldn't handle the request.

Of course I suspected the address format I'm using, but the same program
works fine on SCO Unix and I've tried everything I could think of....

I know there must be something, because RFS has been implemented above TLI on
this machine and seems to be working fine. Unfortunatly, I couldn't trace any
of the RFS binaries since they are all stripped :-<

I have put a simple program at the end of this article that points out
the problem.

Any bit of help would be greatly welcome!

Reply by Email please, I'll summarize if there is enough interest!

Thanx in advance,

-- "Jessie"

------------------------------------------------------------------------------
jcc@adesign.uucp	| "An artificial intelligence is better than none!"
..!inria!adesign!jcc	| "Artificial intelligence matches natural stupidity!"
Collet Jean-Christophe	| "Objets inanimes avez-vous donc une ame ?"
------------------------------------------------------------------------------
Axis Design			|
119, rue de Flandres		|
75019 Paris			|    <this space left intentionaly blank>
France				|
Tel: +33 (1) 40 35 20 20	|
------------------------------------------------------------------------------
--- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/in.h>
#include <netdb.h>
#include <tiuser.h>
    
main (argc, argv)
int	argc;
char*	argv[];
{
	char *device;
	char *host;
	int port;
	struct hostent *hp;
	int fd;
	extern int t_errno, errno;
	struct t_bind bind_req;
	struct t_call *call_req;
	unsigned char call_buf[256];
	int call_len;
	struct t_addr
	    {
		    short type;
		    short port;
		    long addr;
	    }
	bind_addr, *call_addr;
	
	
	extern int optind;
	extern char *optarg;
	int c;
	
	host = "santafe";
	port = 6000;
	device = "/dev/tcp";
	call_len = 0;
	
	while ((c = getopt (argc, argv, "p:h:d:x:")) != EOF)
	    switch (c)
		{
		      case 'd':
			device = optarg;
			break;
		      case 'h':
			host = optarg;
			break;
		      case 'p':
			port = atoi(optarg);
			break;
		      case 'x':
			{
				int n;
				
				for (n = 0; optarg[2*n] && optarg[2*n+1]; n++)
				    {
					    int h;
					    sscanf (&optarg[2*n], "%02x", &h);
					    call_buf[n] = h;
				    }
				call_len = n;
				break;
			}
		}
	
	if ((fd = t_open (device, O_RDWR, NULL)) < 0) {
		t_error("t_open failed");
		fprintf(stderr, "t_errno=%d errno=%d\n", t_errno, errno);
		exit(1);
	}
	
	if (t_bind (fd, NULL, NULL) < 0) {
		t_error("t_bind failed");
		fprintf(stderr, "t_errno=%d errno=%d\n", t_errno, errno);
		exit(1);
	}
	
	if((call_req = (struct t_call *) t_alloc(fd, T_CALL, T_ALL)) == 0) {
		t_error("t_alloc failed");
		fprintf(stderr, "t_errno=%d errno=%d\n", t_errno, errno);
		exit(1);
	}
	
	call_addr = (struct t_addr *) malloc(sizeof(struct t_addr));
	
	if (call_len == 0) {
		call_addr->type = htons(AF_INET);
		call_addr->port = htons(port);
		hp = gethostbyname (host);
		call_addr->addr = *(long *)hp->h_addr;
		
		call_req->addr.len = sizeof(struct t_addr);
		fprintf(stderr,"maxlen = %d\n",call_req->addr.maxlen);
		memcpy(call_req->addr.buf , call_addr, sizeof(struct t_addr));
	} else {
		call_req->addr.len = call_len;
		call_req->addr.maxlen = call_len;
		call_req->addr.buf = (char *) &call_buf[0];
	}
	
	call_req->opt.len =0;
	call_req->udata.len = 0;
	if (t_connect (fd, call_req, NULL) < 0)
	    {
		    t_error("t_connect failed");
		    fprintf(stderr, "t_errno=%d errno=%d\n", t_errno, errno);
		    exit(1);
	    }
	
	exit(0);
}