🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #863

Re: binding sockets

#863
From: Jonathan I. Kamens
Date: Sun, 16 Sep 1990 18:37
26 lines
1467 bytes
In article <ERAN.90Sep14175746@adelbert9.stanford.edu>, eran@adelbert9.stanford.edu (eran yehudai) writes:
|> It seems the namelen parameter one passes bind() should be
|> 2 + strlen(socketname), and then everything works. 

  No, actually, the namelen parameter one passes to bind() should be the
sizeof the sockaddr structure being passed into it, e.g. (error checking
omitted):

   #include <sys/types.h>
   #include <sys/socket.h>
   #include <sys/un.h>
   #include <strings.h>

   struct sockaddr_un name;
   int s;

   name.sun_family = AF_UNIX;
   strcpy(name.sun_path, "/tmp/testsocket");
   s = socket(PF_UNIX, SOCK_STREAM, 0);
   bind(s, &name, sizeof(name));

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710
Technical Details
Message-ID: <1990Sep16.183730.18698@athena.mit.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!athena.mit.edu!jik
References: <ERAN.90Sep14115242@elaine7.stanford.edu> <ERAN.90Sep14175746@adelbert9.stanford.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!athena.mit.edu!jik
From: jik@athena.mit.edu (Jonathan I. Kamens)
Newsgroups: comp.unix.programmer
Subject: Re: binding sockets
Message-ID: <1990Sep16.183730.18698@athena.mit.edu>
Date: 16 Sep 90 18:37:30 GMT
References: <ERAN.90Sep14115242@elaine7.stanford.edu> <ERAN.90Sep14175746@adelbert9.stanford.edu>
Sender: daemon@athena.mit.edu (Mr Background)
Reply-To: jik@athena.mit.edu (Jonathan I. Kamens)
Distribution: comp
Organization: Massachusetts Institute of Technology
Lines: 26