Novell Home

Gethostid from CLIB

From Developer Community

Shows how to call gethostid from CLIB.

Sample Code

#include <ctype.h>
#include <stdio.h>
#include <netdb.h>
#include <stdlib.h>
#include <sys/types.h>
#include <nlm/sys/socket.h>
#include <nlm/sys/bsdskt.h>
#include <netinet/in.h>
#include <arpa/inet.h>


NETDB_DEFINE_CONTEXT

int main(void)
{
	char buff[255];
	struct sockaddr_in localAddr;	
	memset(buff, 0, sizeof(buff));
	printf("hello\r\n");
	localAddr.sin_addr.s_addr = gethostid();
	printf("%s\r\n", NWinet_ntoa(buff, localAddr.sin_addr));
	return 1;
}

--Benjamin Fjeldsted

Novell® Making IT Work As One

© 2009 Novell, Inc. All Rights Reserved.