From the course: Network Programming in C: Develop Reliable Client/Server Applications
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Explore the getaddrinfo() function - C Tutorial
From the course: Network Programming in C: Develop Reliable Client/Server Applications
Explore the getaddrinfo() function
- [Instructor] For most network programming, the getaddrinfo function plays a vital role. Its job is to set up and configure the connection. This function helps configure a server or client and it can be used with the TCP or UDP protocols. It requires including the sys/socket.h and netdb header files. Also include the sys/types.h header file to use certain constants. Here is the getaddrinfo function's format. It requires four arguments. A string representing the network host, a name or IP address, a string representing the service or port. The last two items are addrinfo structures, the address of a hints structure which helps configure the connection, and the address of a resource pointer, a double pointer, which stores the results. Yes, this function does a lot and it's complex, so follow along closely. The getaddrinfo function's first argument is a node. Consider it a network address. It can be a string such as…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.