home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!cs.utexas.edu!hermes.chpc.utexas.edu!news.utdallas.edu!corpgate!crchh327!crchh453!minyard
- From: minyard@crchh453.bnr.ca (Corey Minyard)
- Subject: Problems with domain sockets in porting lpr
- Message-ID: <1992Aug27.165912.24167@bnr.ca>
- Keywords: domain sockets, linux
- Sender: news@bnr.ca (News on crchh327)
- Nntp-Posting-Host: crchh453
- Reply-To: minyard@bnr.ca
- Organization: BNR
- Date: Thu, 27 Aug 1992 16:59:12 GMT
- Lines: 36
-
- I have ported plp (a public lpr spooling package) to linux but I have
- experienced a problem with domain sockets. If I do the following:
-
- struct sockaddr_un saddr;
- int s;
-
- s = socket(AF_UNIX, SOCK_STREAM, 0);
- if (s < 0)
- {
- error
- }
- else
- {
- saddr.sun_family = AF_UNIX;
- strcpy(saddr.sun_path, filename);
-
- if (bind(s, &saddr, sizeof(saddr)) < 0)
- {
- error...
-
- The bind will fail. I turned on socket debugging and found it was getting
- an invalid length. It turns out if you pass "sizeof(saddr)" to bind
- (or connect) if fails. I looked in the kernel, and that is what it was
- coded to do.
-
- Is this behavior correct? I changed the size to be
-
- sizeof(saddr.sun_family) + strlen(filename)
-
- and it worked just fine. The documentation I have on domain sockets
- mentions nothing about this.
-
- ----------------------------------------------------------------------
-
- Corey Minyard
- minyard@bnr.ca
-