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,500 courses taught by industry experts.
Obtain the client's address - C Tutorial
From the course: Network Programming in C: Develop Reliable Client/Server Applications
Obtain the client's address
- [Instructor] With caller ID, you know, who's calling you. Their name appears on the smartphone screen before you answer. A server can also ID the caller obtaining their IP address when you use the getnameinfo function. This function obtains the host name and service name for a connection. The address information is held in a sockaddr structure which is what a server uses to connect with a client. The function obtains two strings and their lengths, one for the host name and a second for the service name. This function has a whopping seven arguments: the address of a sockaddr structure to hold the client's address, the client's address size, a character buffer to store the host or name, the character buffer size, a character buffer to store the service name, the service name buffer size, and a flags value. They getnameinfo function returns 0 upon success or an error value otherwise. This function requires including the…
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.