silvaunix Posted July 23, 2024 at 06:50 PM Report Share #633299 Posted July 23, 2024 at 06:50 PM boa tarde! estou com um problema para programar um socket com ipv6..... #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/socket.h> #include <sys/types.h> #include <arpa/inet.h> #include <netdb.h> #include <unistd.h> int main(){ char sala[]={"/join #sala"}; char nick[]={"nick"}; char dados[4096]; struct sockaddr_in addr = { .sin_family = AF_INET6, .sin_port = htons(6667), .sin_addr.s_addr = inet_addr("2600:3c00::f03c:91ff:fe96:a2a3") }; int sk = socket(AF_INET6, SOCK_STREAM, 0); if(sock == -1){ perror("socket error"); exit(1); } int x = connect(sk, (struct sockaddr*)&addr, sizeof(addr)); if(cnx == -1){ perror("connect error"); exit(1); } send(sk, nick, strlen(nick), 0); send(sk, nick, strlen(nick), 0); send(sk, sala, strlen(sala), 0); recv(sk, dados, 4096, 0); puts(dados); close(x); close(sk); return 0; } podem me ajudar, por favor? Link to comment Share on other sites More sharing options...
Solution silvaunix Posted July 25, 2024 at 02:43 AM Author Solution Report Share #633310 Posted July 25, 2024 at 02:43 AM problema resolvido, eu esqueci do netinet/in.h Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now