-/* $Id: telnetd.c,v 1.13 2004/09/14 17:24:58 bug1 Exp $
- *
+/* vi: set sw=4 ts=4: */
+/*
* Simple telnet server
* Bjorn Wesen, Axis Communications AB (bjornw@axis.com)
*
- * This file is distributed under the Gnu Public License (GPL),
- * please see the file LICENSE for further information.
+ * Licensed under GPL, see file LICENSE in this tarball for details.
*
* ---------------------------------------------------------------------------
* (C) Copyright 2000, Axis Communications AB, LUND, SWEDEN
/* Grab a TCP socket. */
- master_fd = socket(SOCKET_TYPE, SOCK_STREAM, 0);
- if (master_fd < 0) {
- bb_perror_msg_and_die("socket");
- }
+ master_fd = bb_xsocket(SOCKET_TYPE, SOCK_STREAM, 0);
(void)setsockopt(master_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
/* Set it to listen to specified port. */
sa.sin_addr = bind_addr;
#endif
- if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
- bb_perror_msg_and_die("bind");
- }
-
- if (listen(master_fd, 1) < 0) {
- bb_perror_msg_and_die("listen");
- }
-
- if (daemon(0, 0) < 0)
- bb_perror_msg_and_die("daemon");
-
+ bb_xbind(master_fd, (struct sockaddr *) &sa, sizeof(sa));
+ bb_xlisten(master_fd, 1);
+ bb_xdaemon(0, 0);
maxfd = master_fd;
#endif /* CONFIG_FEATURE_TELNETD_INETD */