4.1cBSD/usr/src/lib/libc/net/common/getservbyport.c

Compare this file to the similar file:
Show the results in this format:

/*	getservbyport.c	4.2	82/10/05	*/

#include <netdb.h>

struct servent *
getservbyport(port, proto)
	int port;
	char *proto;
{
	register struct servent *p;

	setservent(0);
	while (p = getservent()) {
		if (p->s_port != port)
			continue;
		if (proto == 0 || strcmp(p->s_proto, proto) == 0)
			break;
	}
	endservent();
	return (p);
}