Changeset 60:d1fa94aadc08 in roaraudio for libroar


Ignore:
Timestamp:
07/12/08 12:19:08 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added basic UNIX Domain Socket code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/socket.c

    r2 r60  
    6565 int fh; 
    6666 struct sockaddr_in   socket_addr; 
     67 struct sockaddr_un   socket_addr_un; 
    6768 struct hostent     * he; 
    6869 //unsigned int host_div = 0; 
     
    8283             type == ROAR_SOCKET_TYPE_UNIX ? "UNIX" : "INET", host, port); 
    8384 
    84  memset(&socket_addr, 0, sizeof(socket_addr)); 
    85  memset(&he,          0, sizeof(he)); 
     85 memset(&socket_addr   , 0, sizeof(socket_addr)); 
     86 memset(&socket_addr_un, 0, sizeof(socket_addr_un)); 
     87 memset(&he,             0, sizeof(he));               // FIXME: we have a valid pointer in here???? 
    8688 
    8789 
     
    109111  // hey! we have a socket... 
    110112 } else { 
     113  socket_addr_un.sun_family = AF_UNIX; 
     114  strncpy(socket_addr_un.sun_path, host, sizeof(socket_addr_un.sun_path) - 1); 
     115 
    111116  fh = roar_socket_new_unix(); 
    112   close(fh); 
    113   return -1; 
     117 
     118  if ( mode_func(fh, (struct sockaddr *)&socket_addr_un, sizeof(struct sockaddr_un)) == -1 ) { 
     119   ROAR_DBG("roar_socket_open(*): Can not connect/bind: %s", strerror(errno)); 
     120   close(fh); 
     121   return -1; 
     122  } 
    114123 } 
    115124 
Note: See TracChangeset for help on using the changeset viewer.