I have some experience in network programming in C but in my new project I have/wnat to use c++. My question is now a bit general, are there any c++ specific libraries already available for the network programming or do I just use the same methods as in C? E.g. for getting IP address in C I would do something like:
fd = socket(AF_INET, SOCK_DGRAM, 0);
ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name, "eth0", IFNAMSIZ-1);
ioctl(fd, SIOCGIFADDR, &ifr);
strncpy(ip, inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr), IP_ADDR_LEN);
ioctl(fd, SIOCGIFNETMASK, &ifr);
strncpy(netmask, inet_ntoa(((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr), IP_ADDR_LEN);
close(fd);
I know I can simply use the same code in c++, but would there be any Classes with methods to make it "easier"?