INADDR_NONE, not -1; bug report 4.3BSD/lib/22
[unix-history] / usr / src / lib / libc / net / getservbyport.c
... / ...
CommitLineData
1/*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
7#if defined(LIBC_SCCS) && !defined(lint)
8static char sccsid[] = "@(#)getservbyport.c 5.3 (Berkeley) %G%";
9#endif LIBC_SCCS and not lint
10
11#include <netdb.h>
12
13extern int _serv_stayopen;
14
15struct servent *
16getservbyport(port, proto)
17 int port;
18 char *proto;
19{
20 register struct servent *p;
21
22 setservent(_serv_stayopen);
23 while (p = getservent()) {
24 if (p->s_port != port)
25 continue;
26 if (proto == 0 || strcmp(p->s_proto, proto) == 0)
27 break;
28 }
29 if (!_serv_stayopen)
30 endservent();
31 return (p);
32}