Back to index

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

Go to the source code of this file.

Functions

int __socket (int domain, int type, int protocol)

Function Documentation

int __socket ( int  domain,
int  type,
int  protocol 
)

Definition at line 30 of file socket.c.

{
  error_t err;
  socket_t sock, server;

  /* Find the socket server for DOMAIN.  */
  server = _hurd_socket_server (domain, 0);
  if (server == MACH_PORT_NULL)
    return -1;

  err = __socket_create (server, type, protocol, &sock);
  if (err == MACH_SEND_INVALID_DEST || err == MIG_SERVER_DIED
      || err == MIG_BAD_ID || err == EOPNOTSUPP)
    {
      /* On the first use of the socket server during the operation,
        allow for the old server port dying.  */
      server = _hurd_socket_server (domain, 1);
      if (server == MACH_PORT_NULL)
       return -1;
      err = __socket_create (server, type, protocol, &sock);
    }

  /* These errors all mean that the server node doesn't support the
     socket.defs protocol, which we'll take to mean that the protocol
     isn't supported.  */
  if (err == MACH_SEND_INVALID_DEST || err == MIG_SERVER_DIED
      || err == MIG_BAD_ID || err == EOPNOTSUPP)
    err = EPFNOSUPPORT;

  if (err)
    return __hurd_fail (err);

  return _hurd_intern_fd (sock, O_IGNORE_CTTY, 1);
}

Here is the call graph for this function: