Multiple connections on a single port?

David S. Goldberg dsg at mbunix.mitre.org
Sat Jan 7 05:36:08 AEST 1989


In article <43380 at linus.UUCP> I writes:
>
>I appologize if this question is incredibly simple or obvious...

	And after discovering my stupid mistake, I really appolgize :-)

[problem with multiple connections being cued]

>----------------------------------------------------------------------
>
>main(argc,argv)
>int argc;
>char **argv;
>{

[ no need to see all the gory details again]

>			g = accept(f,&from,&len);
>		} while (g < 0 && errno == EINTR);
>		from.sin_port = ntohs((u_short)from.sin_port);
>		hp = gethostbyaddr(&from.sin_addr, sizeof (struct in_addr),
>			from.sin_family);
>		hname = (char *) malloc(strlen (hp->h_name) + 1);
>		strcpy(hname,hp->h_name);
>		if (approved(hname)) { /* only certain hosts can connect */
>			if ((pid = fork()) == 0) {
>				close(f);
>				authenticate(g); /* routine talks to client*/
>				return;
				^^^^^^^

ARRGH I should have used exit.  And looking through my RCS logs, I found
that at one point I had.  I don't even remember changing it.  I think the
reason why is that the descriptor g doesn't close properly, but could
someone tell me for sure?

>			}
>			close(g);
>		}
>		else close(g);

Thanks,

-dave
--------------------------------------------------------------------------
Dave Goldberg	             ARPA: dsg at mitre.org
The Mitre Corporation
MS B020                      UUCP: linus!mbunix!dsg
Bedford, MA 01730
617-271-2460



More information about the Comp.unix.wizards mailing list