alsa.audio: limit the supported frequencies to common set
[AROS.git] / workbench / network / stacks / AROSTCP / netlib / init_inet_daemon.c
blob009541f646854d44f4ec3cf19204648e96ce80b3
1 /* $Id$
3 * init_inet_daemon.c - obtain socket accepted by the inetd
5 * Copyright © 1994 AmiTCP/IP Group,
6 * Network Solutions Development Inc.
7 * All rights reserved.
8 */
10 /****** net.lib/init_inet_daemon ****************************************
12 NAME
13 init_inet_daemon - obtain socket accepted by the inetd
15 SYNOPSIS
16 int init_inet_daemon(void);
18 FUNCTION
19 Obtain the server socket accepted by the inetd, the Internet
20 super-server.
22 RETURN VALUES
23 socket descriptor if successful, -1 with specific error code
24 on errno otherwise.
26 ERRORS
27 ENXIO - The process was not started by the inetd.
29 NOTES
30 If the process was started by the inetd, but the ObtainSocket()
31 call fails, then this function exit()s with some specific exit
32 code, so that inetd can clean up the unobtained socket.
34 Use the net.lib function set_socket_stdio() to redirect stdio,
35 stdout and stderr to the returned socket, if necessary.
37 SEE ALSO
38 serveraccept(), set_socket_stdio(), bsdsocket/ObtainSocket(),
39 netutil/inetd
40 *****************************************************************************
44 #include <exec/types.h>
45 #include <dos/dosextens.h>
47 #include <proto/socket.h>
48 #include <proto/exec.h>
50 #include <stdlib.h>
51 #include <errno.h>
52 #include <inetd.h>
54 int
55 init_inet_daemon(void)
57 struct Process *me = (struct Process *)FindTask(NULL);
58 struct DaemonMessage *dm = (struct DaemonMessage *)me->pr_ExitData;
59 int sock;
61 if (dm == NULL) {
63 * No DaemonMessage, return error code
64 */
65 errno = ENXIO; /* "Device not configured" */
66 return -1;
70 * Obtain the server socket
72 sock = ObtainSocket(dm->dm_Id, dm->dm_Family, dm->dm_Type, 0);
73 if (sock < 0) {
75 * If ObtainSocket fails we need to exit with this specific exit code
76 * so that the inetd knows to clean things up
78 exit(DERR_OBTAIN);
81 return sock;