trouble with asynchronous I/O on UNIX domain stream sockets

James Pinakis jamesp at wacsvax.OZ
Mon Oct 2 18:11:02 AEST 1989


I'm having trouble setting getting UNIX domain sockets to notify me
when data is ready to read (using 4.3bsd UNIX).  I create and connect
the socket using

	sock = socket(AF_UNIX, SOCK_STREAM, 0);
	if (sock < 0) {
		perror("opening stream socket");
		exit(1);
	}
	server.sun_family = AF_UNIX;
	strcpy(server.sun_path, "/tmp/sock");

	if (connect(sock, &server, sizeof(server)) < 0) {
		close(sock);
		perror("connecting stream socket");
		exit(1);
	}

And set it up to be asynchronous and non-blocking in the way specified
in the manual.  I set up a simple handler for SIGIO which attempts to
read a byte off the socket and print a message if it can't.  I've also
started up a server process which accepts connections, then forks of
a process which contains only an infinite loop.

I want to do bidirectional I/O on this descriptor, but as soon as I write
anything on it (from this process), I get a SIGIO.  The handler, however,
is unable to read any data off the descriptor and prints the error message.

I've had a very similar program using Internet domain stream sockets working
without any trouble at all.  I could read and write on the same descriptor
and never get any spurious SIGIOs.  Is there some fundamental difference
between Unix domain and Internet domain stream sockets which may be
preventing me from using them in this way?

Any help at all would be most appreciated.

--
James Pinakis

Department of Computer Science,   ACSnet:   jamesp at wacsvax.oz
University of Western Australia,  ARPA:     jamesp%wacsvax.oz at uunet.uu.net
Nedlands WA 6009,                 UUCP:     ..!uunet!munnari!wacsvax!jamesp
AUSTRALIA
PHONE:  (09) 380 2305             OVERSEAS: +61 9 380 2305



More information about the Comp.unix.wizards mailing list