Snort mailing list archives

yet another unix socket question...


From: "Dr. Richard W. Tibbs" <ccamp () oakcitysolutions com>
Date: Sat, 12 Jan 2002 13:38:43 -0500

Dear list :

After searching the archives (and finding a few postings; thanks to Fyodor) I am still not able to figure out my problem. I am trying to write a reciever socket program to use with snort using the output alert to unixsock facility.

The attached code snipet fails upon the bind command, with errno 98.
I have debugged the code in kdb and the myname struct looks fine, as does the sock variable.

Any idea what is wrong ?

Thanks in advance....



  sock = socket(AF_UNIX, SOCK_DGRAM, 0);
  if (sock < 0) {
    printf("socket failure %d\n", errno);
    exit(1);
  }

  myname.sa_family = AF_UNIX;
  strcpy(myname.sa_data, "/tmp/somefile");
  addrlen =  strlen(myname.sa_data) + sizeof(myname.sa_family) ;
  if (bind(sock, (struct sockaddr *) &myname, addrlen ) < 0) {
    printf("bind failure %d\n", errno);
    exit(1);
  }

  cnt = recvfrom(sock, buf, sizeof(buf),
    0, &from_name, &fromlen);

/* etc.... */

Current thread: