bin@primate.wisc.edu (Brain in Neutral) (07/22/89)
Anyone know how to get UNIX domain sockets to work in RISC/os 4.0? (This
is on an M/120.) In 3.0, sockets in this domain were not supported at
all; I am happy to see they are included in 4.0, but would be happier
yet if I could get them to work. The following works on a VAX (Ultrix 1.2
or 2.2), but not on a MIPS:
static int sock;
static openserver ()
{
struct sockaddr_un sun;
sock = socket (AF_UNIX, SOCK_STREAM, 0);
if (sock < 0)
{
perror ("socket");
return (-1);
}
bzero ((char *) &sun, sizeof (sun));
sun.sun_family = AF_UNIX;
strcpy (sun.sun_path, socketFile);
if (connect (sock, &sun, strlen (sun.sun_path)
+ sizeof (sun.sun_family)) == 0)
return (0); /* everything ok */
perror ("connect");
close (sock);
return (-1);
}
static writeserver (s)
char *s;
{
if (write (sock, s, strlen (s)) < 0)
{
perror ("write");
return (-1);
}
return (0);
}
The socket() and connect() calls work ok, but the write fails with
"write: Socket is not connected". What gives?
Paul DuBois
dubois@primate.wisc.edu