So I have to connect to a server on a specific port but all I have to identify the server is its name, e.g. "students.ce.sinclair.edu" in a char*. How can I get the ip address to assign to a sockaddr_in?

struct sockaddr_in server;
memset($server, 0, sizeof(server));
server.sin_family = AF_INET;
//server.sin_addr.s_addr = ->students.ce.sinclair.edu<-
server.sin_port = ####;

gethostbyname() sounds promising but I can't find a decent example. Any help would be greatly appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.