Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!sdd.hp.com!ucsd!ucbvax!ANDREW.CMU.EDU!vd09+ From: vd09+@ANDREW.CMU.EDU ("Vincent M. Del Vecchio") Newsgroups: comp.protocols.tcp-ip Subject: Telnettable programs Message-ID: Date: 31 Aug 90 23:53:33 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 68 I am trying to write a network daemon-type program which will not be called from inetd, but which other users can telnet to. However, when I try to telnet, I get a connection refused. I can write another program which will connect fine, but telnet seems to be looking for something else. I looked at the code for inetd (which handles these things for most daemons) and it was a bit of a mess, but the only thing that I saw was that I might not have been setting socket options that I needed to. Does anyone have any ideas? The relevant portion of the code follows: #include #include #include #include #include #include main() { struct sockaddr_in sockad, oend; int sock, accepteds, size = sizeof (sockad), osize = sizeof (oend), buf[100]; if ((sock = socket(AF_INET, SOCK_STREAM, 0, 0)) == -1) perror ("creating socket"), exit(1); sockad.sin_family = AF_INET; sockad.sin_port = 3007; /* The port we'll try to telnet to */ sockad.sin_addr.S_un.S_addr = INADDR_ANY; if (bind (sock, &sockad, sizeof (sockad)) == -1) perror ("binding socket"), exit(1); if (getsockname (sock, &sockad, &size) == -1) perror ("Bad address for socket"), exit(1); printf ("%d\\n",sockad.sin_port); if (listen (sock,5) == -1) perror ("listening on socket"), exit(1); printf ("Waiting\\n"); do { errno = 0; osize = sizeof (oend); accepteds = accept(sock, &oend, &osize); } while (accepteds == -1 && errno == EINTR); if (accepteds == -1) perror ("accepting on socket"), exit(1); printf ("Accepted"); process(accepteds); } It's not very well (or at all) commented, but it's fairly short. It prints out the port number 3007, and "Waiting" and then sits... when I try to telnet, it says "Connection refused," and the program doesn't do anything; just keeps waiting. I would very much appreciate any ideas. TIA, and, as I don't read this board normally, please respond via email. If there is interest (please mail me also) I will summarize. +----------------------------------------------------------------------------+ | Vincent Del Vecchio \ vd09+@andrew.cmu.edu | | Box 4872 \ Reserved for another email address. | | 5125 Margaret Morrison St.\ Reserved for a quote | | Pittsburgh, PA 15213 \ Reserved for a standard disclaimer | +----------------------------------------------------------------------------+