Jump to content

bot irc


silvaunix
Go to solution Solved by silvaunix,

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.