comparison rvinterf/etmsync/connect.c @ 276:909f00c15f27

more fc-fsio foundation
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 23 Feb 2014 21:31:30 +0000
parents cedf09b6b5ac
children 7b805007dcfc
comparison
equal deleted inserted replaced
275:cedf09b6b5ac 276:909f00c15f27
10 #include <strings.h> 10 #include <strings.h>
11 #include <stdlib.h> 11 #include <stdlib.h>
12 #include <unistd.h> 12 #include <unistd.h>
13 #include "pktmux.h" 13 #include "pktmux.h"
14 #include "localsock.h" 14 #include "localsock.h"
15 #include "exitcodes.h"
15 16
16 extern char *socket_pathname; 17 extern char *socket_pathname;
17 extern int sock; 18 extern int sock;
18 19
19 connect_local_socket() 20 connect_local_socket()
24 int rc; 25 int rc;
25 26
26 sock = socket(AF_UNIX, SOCK_STREAM, 0); 27 sock = socket(AF_UNIX, SOCK_STREAM, 0);
27 if (sock < 0) { 28 if (sock < 0) {
28 perror("socket(AF_UNIX, SOCK_STREAM, 0)"); 29 perror("socket(AF_UNIX, SOCK_STREAM, 0)");
29 exit(1); 30 exit(ERROR_UNIX);
30 } 31 }
31 32
32 local.sun_family = AF_UNIX; 33 local.sun_family = AF_UNIX;
33 strncpy(local.sun_path, socket_pathname, sizeof(local.sun_path)); 34 strncpy(local.sun_path, socket_pathname, sizeof(local.sun_path));
34 local.sun_path[sizeof(local.sun_path) - 1] = '\0'; 35 local.sun_path[sizeof(local.sun_path) - 1] = '\0';
46 #endif 47 #endif
47 48
48 rc = connect(sock, (struct sockaddr *) &local, namelen); 49 rc = connect(sock, (struct sockaddr *) &local, namelen);
49 if (rc != 0) { 50 if (rc != 0) {
50 perror(socket_pathname); 51 perror(socket_pathname);
51 exit(1); 52 exit(ERROR_RVINTERF);
52 } 53 }
53 54
54 return(0); 55 return(0);
55 } 56 }