#include <netdb.h> struct protoent *getprotoent(void); struct protoent *getprotobyname(const char *name); struct protoent *getprotobynumber(int proto); void setprotoent(int stayopen); void endprotoent(void);
getprotobyname() 함수는 /etc/protocols 에서 프로토콜 이름 name과 일치하는 라인에 해당하는 protoent 구조체를 반환한다.
getprotobynumber() 함수는 프로토콜 번호 number과 일치하는 라인에 해당하는 protoent 구조체를 반환한다.
setprotoent() 함수는 /etc/protocols 파일을 읽고 되 감는다. 만일 stayopen 가 참(1)이라면, 파일은 getprotobyname() 나 getprotobynumber() 호출시 닫혀지지 않는다.
endprotoent() 함수는 /etc/protocols를 닫는다.
protoent 구조체는 다음처럼 <netdb.h> 에 정의되어 있다:
struct protoent {
char *p_name; /* 공식적인 프로토콜 이름 */
char **p_aliases; /* 별칭 리스트 */
int p_proto; /* 프로토콜 번호 */
}
protoent 구조체의 멤버는: