Back to index

glibc  2.9
Functions
connect.c File Reference
#include <errno.h>
#include <hurd.h>
#include <hurd/fd.h>
#include <sys/socket.h>
#include <hurd/socket.h>
#include <sys/un.h>
#include <hurd/ifsock.h>

Go to the source code of this file.

Functions

int __connect (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len)

Function Documentation

int __connect ( int  fd,
__CONST_SOCKADDR_ARG  addrarg,
socklen_t  len 
)

Definition at line 34 of file connect.c.

{
  error_t err;
  addr_port_t aport;
  const struct sockaddr_un *addr = addrarg.__sockaddr_un__;

  if (addr->sun_family == AF_LOCAL)
    {
      /* For the local domain, we must look up the name as a file and talk
        to it with the ifsock protocol.  */
      file_t file = __file_name_lookup (addr->sun_path, 0, 0);
      if (file == MACH_PORT_NULL)
       return -1;
      err = __ifsock_getsockaddr (file, &aport);
      __mach_port_deallocate (__mach_task_self (), file);
      if (err == MIG_BAD_ID || err == EOPNOTSUPP)
       /* The file did not grok the ifsock protocol.  */
       err = ENOTSOCK;
      if (err)
       return __hurd_fail (err);
    }
  else
    err = EIEIO;

  err = HURD_DPORT_USE (fd,
                     ({
                       if (err)
                         err = __socket_create_address (port,
                                                    addr->sun_family,
                                                    (char *) addr, len,
                                                    &aport);
                       if (! err)
                         {
                           err = __socket_connect (port, aport);
                           __mach_port_deallocate (__mach_task_self (),
                                                aport);
                         }
                       err;
                     }));

  return err ? __hurd_dfail (fd, err) : 0;
}

Here is the call graph for this function: