title: Client program in c for ipv6 connect is not working?
body: <p>/<em>client.c</em>/</p>
  <pre><code> void main()
     {
      static int s = 0;
      char url_or_ip[130] = {0};
      int port = 0;
      ip_type_or_dns_enum ip_dns_type = -1;
      char *sptr = ext_sio_recv_buff;
      char *ip_str = NULL;
      char ip_buf[128] = {0};
      int isipv6 = 0;
      char buff[NWY_UART_RECV_SINGLE_MAX + 1] = {0};
      int on = 1;
      int opt = 1, ret = 0, send_len;
      uint64_t start;
      ip6_addr_t addr;
      struct sockaddr_in6 sa;
      struct sockaddr_in6 *to6 = (struct sockaddr_in6 *)&amp;sa;
      port = 8000;
      addr.addr[0] =  0x25035959;
      addr.addr[1] =  0x87493683; 
      addr.addr[2] =  0x2abf3de2; 
      addr.addr[3] =  0x1ab43f8e;
  
  
  
     /*socket creation*/
  
      s = socket_open(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
      sa.sin6_len = sizeof(struct sockaddr_in6);
      sa.sin6_family = AF_INET6;
      sa.sin6_port = htons(port);
     
     /*assigning the address for ipv6*/
  
      sa.sin6_addr.un.u32_addr[0] = htonl(addr.addr[0]);
      sa.sin6_addr.un.u32_addr[1] = htonl(addr.addr[1]);
      sa.sin6_addr.un.u32_addr[2] = htonl(addr.addr[2]);
      sa.sin6_addr.un.u32_addr[3] = htonl(addr.addr[3]);
  
  socket_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void *)&amp;on,sizeof(on));
  socket_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (void *)&amp;opt, sizeof(opt));
   
    /*connect to the particular server*/  
  
    int ret = socket_connect(s, (struct sockaddr *)&amp;sa, sizeof(sa));
      if(ret &gt;0)
      {
      socket_send(s, uart_rec_buffer, uart_length, 0);
      socket_shutdown(s, SHUT_RD);
      socket_close(s);
      s=0;
      }
    }
  </code></pre>
  <p>here i am trying to make ipv6 client connection to the ipv6 server, but in the connect system call it is failing . i tried to change the ip and checked still same issue. But the code fails in connect system call and returning -1 and showing invalid argument. Any suggestions. And the API's i am using are similar to the socket programming api's and the socket_open is similar to the socket creation and the socket_connect is similar to the connect system call and assinging the values to the ipv6 predefined structures, the socket is created successfully but socket_connect is failed, why? and it is showing invalid argument passed to the connect call..</p>