0
가능한 중복 :상당합니다 inet_addr, 리눅스
:const char* interface = "10.123.123.123"; struct ip_mreq mc_req; mc_req.imr_interface.s_addr = inet_addr(interface);
Get IP address of an interface on linux
나는 다음과 같은 코드가 있습니다
여기서 인터페이스은 내가 원하는 인터페이스의 inet 주소입니다. 용도.
대신 이름으로으로 인터페이스를 참조 할 수 있습니까?
예를 들어, 내가 좋아하는 뭔가를 쓰고 싶은 :
const char* interface = "eth0";
struct ip_mreq mc_req;
mc_req.imr_interface.s_addr = inet_addr(interface); // ???
을하지만 그것은 작동하지 않습니다. "eth0"을 참조하는 inet 주소를 조회 할 수있는 inet_addr과 유사한 기능이 있습니까?
참고 : SO 검색 창은 친구입니다.;) –