home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / linux / 9214 < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.4 KB  |  50 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!cs.utexas.edu!hermes.chpc.utexas.edu!news.utdallas.edu!corpgate!crchh327!crchh453!minyard
  3. From: minyard@crchh453.bnr.ca (Corey Minyard)
  4. Subject: Problems with domain sockets in porting lpr
  5. Message-ID: <1992Aug27.165912.24167@bnr.ca>
  6. Keywords: domain sockets, linux
  7. Sender: news@bnr.ca (News on crchh327)
  8. Nntp-Posting-Host: crchh453
  9. Reply-To: minyard@bnr.ca
  10. Organization: BNR
  11. Date: Thu, 27 Aug 1992 16:59:12 GMT
  12. Lines: 36
  13.  
  14. I have ported plp (a public lpr spooling package) to linux but I have
  15. experienced a problem with domain sockets.  If I do the following:
  16.  
  17.    struct sockaddr_un   saddr;
  18.    int                  s;
  19.  
  20.    s = socket(AF_UNIX, SOCK_STREAM, 0);
  21.    if (s < 0)
  22.    {
  23.       error
  24.    }
  25.    else
  26.    {
  27.       saddr.sun_family = AF_UNIX;
  28.       strcpy(saddr.sun_path, filename);
  29.       
  30.       if (bind(s, &saddr, sizeof(saddr)) < 0)
  31.       {
  32.          error...
  33.  
  34. The bind will fail.  I turned on socket debugging and found it was getting
  35. an invalid length.  It turns out if you pass "sizeof(saddr)" to bind
  36. (or connect) if fails.  I looked in the kernel, and that is what it was
  37. coded to do.
  38.  
  39. Is this behavior correct?  I changed the size to be 
  40.  
  41.    sizeof(saddr.sun_family) + strlen(filename)
  42.  
  43. and it worked just fine.  The documentation I have on domain sockets
  44. mentions nothing about this.
  45.  
  46. ----------------------------------------------------------------------
  47.  
  48. Corey Minyard
  49. minyard@bnr.ca
  50.