struct sockaddr支持所有网域,如果用ipv4网域,需要强制转换成struct sockaddr_in! struct sockaddr_in { ... struct in_addr sin_addr; };