Need help on rexec/rcmd socket i/o

ip at mill.me.toronto.edu ip at mill.me.toronto.edu
Mon Aug 29 12:14:20 AEST 1988


Can someone give me a hand on this??  The following are what my programs are
doing.  I would apprecicate it if someone could explain to me how
communication is done through the socket and what actually does FIONBIO do
to the socket.  Thank you in advance.

/bevis

Side A: <served by exec/tcp service>
	read from stdin until EOF
	write to stdout
	exit

Side B: (Problem : couldn't read the output from Side A)
	sock = rexec(..., 0);
	ioctl(sock, FIONBIO, &one);
	write(sock, buf, BUFSIZ);
	write(sock, "\0377", 1);
	while((i = read(sock, buf, BUFSIZ)) > 0) write(1, buf, i);

Also tried: (same problem)
	sock = rexec(..., 0);
	for(;;) {
		rfd = wfd = 1<<sock;
		if (select(sock+1, &rfd, &wfd, 0) < 0) break;
		if (wfd) {write(sock, buf, BUFSIZ); write(sock, "\0377", 1);}
		if (rfd) {
			while((i=read(sock, buf, BUFSIZ) > 0) write(1, buf, i);
			break;
		}
	}
-- 
Bevis Ip	University of Toronto, Dept. of Mechanical Engineering
CSNET :  ip at me.toronto.edu		BITNET:  ip at me.UTORONTO
ARPA  :  ip%me.toronto.edu at relay.cs.net
UUCP  :  {allegra,decwrl,decvax!utcsri  pyramid,uunet!utai}!me!ip



More information about the Comp.unix.questions mailing list