Changeset 11df21
- Timestamp:
- 09/29/08 10:16:31 (4 years ago)
- Branches:
- master
- Children:
- 46fd4a
- Parents:
- 6fee7e
- git-author:
- Tomash Brechko <tomash.brechko@…> (09/27/08 17:47:23)
- git-committer:
- Tomash Brechko <tomash.brechko@…> (09/29/08 10:16:31)
- Files:
-
- 2 added
- 3 edited
-
MANIFEST (modified) (1 diff)
-
src/client.c (modified) (1 diff)
-
src/connect.c (modified) (5 diffs)
-
src/socket_posix.c (added)
-
src/socket_posix.h (added)
Legend:
- Unmodified
- Added
- Removed
-
MANIFEST
r787337 r11df21 34 34 src/dispatch_key.c 35 35 src/dispatch_key.h 36 src/socket_posix.c 37 src/socket_posix.h -
src/client.c
rb1cbae r11df21 28 28 #include "dispatch_key.h" 29 29 #include <stdlib.h> 30 #include <unistd.h>31 #include <sys/uio.h>32 30 #include <string.h> 33 31 #include <stdio.h> 34 #include <errno.h> 35 #include <sys/time.h> 36 #include <sys/types.h> 37 #include <sys/socket.h> 32 #include <sys/uio.h> 38 33 #include <signal.h> 39 34 #include <time.h> 40 35 #include <netinet/in.h> 41 36 #include <netinet/tcp.h> 37 #include "socket_posix.h" 42 38 43 39 -
src/connect.c
r6e75c7 r11df21 1 1 /* 2 Copyright (C) 2007 Tomash Brechko. All rights reserved.2 Copyright (C) 2007-2008 Tomash Brechko. All rights reserved. 3 3 4 4 When used to build Perl module: … … 23 23 24 24 #include "connect.h" 25 #include <string.h> 25 26 #include <netdb.h> 26 #include <string.h> 27 #include <sys/types.h> 28 #include <sys/socket.h> 29 #include <sys/un.h> 30 #include <sys/time.h> 31 #include <unistd.h> 32 #include <fcntl.h> 33 #include <errno.h> 34 35 36 /* 37 http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/un.h.html 38 says 92 is a rather safe value. 39 */ 40 #define SAFE_UNIX_PATH_MAX 92 27 #include "socket_posix.h" 41 28 42 29 … … 71 58 for (a = addr; a != NULL; a = a->ai_next) 72 59 { 73 int flags;74 60 fd_set write_set; 75 61 int socket_error; … … 80 66 break; 81 67 82 flags = fcntl(fd, F_GETFL); 83 res = fcntl(fd, F_SETFL, flags | O_NONBLOCK); 68 res = set_nonblock(fd); 84 69 if (res != 0) 85 70 { … … 137 122 client_connect_unix(const char *path, size_t path_len) 138 123 { 139 int fd, res, flags; 140 struct sockaddr_un s_unix; 141 142 if (path_len >= SAFE_UNIX_PATH_MAX) 143 return -1; 144 145 fd = socket(PF_UNIX, SOCK_STREAM, 0); 146 if (fd == -1) 147 return -1; 148 149 s_unix.sun_family = AF_UNIX; 150 memcpy(s_unix.sun_path, path, path_len); 151 s_unix.sun_path[path_len] = '\0'; 152 153 res = connect(fd, (const struct sockaddr *) &s_unix, sizeof(s_unix)); 154 if (res != 0) 155 return -1; 156 157 flags = fcntl(fd, F_GETFL); 158 res = fcntl(fd, F_SETFL, flags | O_NONBLOCK); 159 if (res != 0) 160 return -1; 161 162 return fd; 124 return connect_unix(path, path_len); 163 125 }
Note: See TracChangeset
for help on using the changeset viewer.
