3 * init_inet_daemon.c - obtain socket accepted by the inetd
5 * Copyright © 1994 AmiTCP/IP Group,
6 * Network Solutions Development Inc.
10 /****** net.lib/init_inet_daemon ****************************************
13 init_inet_daemon - obtain socket accepted by the inetd
16 int init_inet_daemon(void);
19 Obtain the server socket accepted by the inetd, the Internet
23 socket descriptor if successful, -1 with specific error code
27 ENXIO - The process was not started by the inetd.
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.
38 serveraccept(), set_socket_stdio(), bsdsocket/ObtainSocket(),
40 *****************************************************************************
44 #include <exec/types.h>
45 #include <dos/dosextens.h>
47 #include <proto/socket.h>
48 #include <proto/exec.h>
55 init_inet_daemon(void)
57 struct Process
*me
= (struct Process
*)FindTask(NULL
);
58 struct DaemonMessage
*dm
= (struct DaemonMessage
*)me
->pr_ExitData
;
63 * No DaemonMessage, return error code
65 errno
= ENXIO
; /* "Device not configured" */
70 * Obtain the server socket
72 sock
= ObtainSocket(dm
->dm_Id
, dm
->dm_Family
, dm
->dm_Type
, 0);
75 * If ObtainSocket fails we need to exit with this specific exit code
76 * so that the inetd knows to clean things up