Address family not supported by protocol

前端 未结 3 928
不思量自难忘°
不思量自难忘° 2021-02-08 01:24

Following code is a socket programming sample for a TCP client.

But when I run this, connect() is returned as Address family not supported by protocol.

I have he

3条回答
  •  余生分开走
    2021-02-08 01:47

    Set the server address like this;

    addr.sin_family = AF_INET;
    addr.sin_addr.s_addr = inet_addr(host);
    addr.sin_port = htons(port);
    

提交回复
热议问题