Changeset 11df21


Ignore:
Timestamp:
09/29/08 10:16:31 (4 years ago)
Author:
Tomash Brechko <tomash.brechko@…>
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)
Message:

Prepare the code for Win32 support.

Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • MANIFEST

    r787337 r11df21  
    3434src/dispatch_key.c 
    3535src/dispatch_key.h 
     36src/socket_posix.c 
     37src/socket_posix.h 
  • src/client.c

    rb1cbae r11df21  
    2828#include "dispatch_key.h" 
    2929#include <stdlib.h> 
    30 #include <unistd.h> 
    31 #include <sys/uio.h> 
    3230#include <string.h> 
    3331#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> 
    3833#include <signal.h> 
    3934#include <time.h> 
    4035#include <netinet/in.h> 
    4136#include <netinet/tcp.h> 
     37#include "socket_posix.h" 
    4238 
    4339 
  • src/connect.c

    r6e75c7 r11df21  
    11/* 
    2   Copyright (C) 2007 Tomash Brechko.  All rights reserved. 
     2  Copyright (C) 2007-2008 Tomash Brechko.  All rights reserved. 
    33 
    44  When used to build Perl module: 
     
    2323 
    2424#include "connect.h" 
     25#include <string.h> 
    2526#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" 
    4128 
    4229 
     
    7158  for (a = addr; a != NULL; a = a->ai_next) 
    7259    { 
    73       int flags; 
    7460      fd_set write_set; 
    7561      int socket_error; 
     
    8066        break; 
    8167 
    82       flags = fcntl(fd, F_GETFL); 
    83       res = fcntl(fd, F_SETFL, flags | O_NONBLOCK); 
     68      res = set_nonblock(fd); 
    8469      if (res != 0) 
    8570        { 
     
    137122client_connect_unix(const char *path, size_t path_len) 
    138123{ 
    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); 
    163125} 
Note: See TracChangeset for help on using the changeset viewer.