File: ux_server_socket.c

package info (click to toggle)
superd 0.0.3-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 136 kB
  • ctags: 85
  • sloc: ansic: 721; makefile: 103; sh: 27
file content (27 lines) | stat: -rw-r--r-- 602 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "ux_server_socket.h"

int ux_server_socket(const char *pipe, const int LISTENQ) {
  int ld; 
  struct sockaddr_un ux_sockaddr;
  
  ux_sockaddr.sun_family = AF_UNIX;
  strcpy(ux_sockaddr.sun_path , pipe);
  
  if ((ld = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
    perror("bind on unix domain socket");
    exit(6);
  }
  
  unlink(pipe);
  
  if ( bind (ld, (struct sockaddr *) &ux_sockaddr, sizeof(ux_sockaddr)) < 0) {
    perror("bind on unix domain socket");
    exit(7);
  }
  
  if ( listen(ld, LISTENQ) < 0) {
    perror("listen on unix domain socket");
    exit(8);
  }
  return(ld);
}