Path: 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: 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 In article , 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 #include #include #include 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