All pastes #458489 Raw Edit

Something

public text v1 · immutable
#458489 ·published 2007-04-25 22:25 UTC
rendered paste body
#include <netdb.h>
#include <string>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include "bot.h"

bot::bot()
{
	strcpy(nick,"NyX");
	strcpy(server,"irc.dawnchat.org");
	strcpy(canal,"#magic");	
	port = 6667;
}

bot::~bot()
{
}

int bot::conecta()
{
	struct hostent *he;
	he = gethostbyname(server);
	if (!he)
	{
		perror("gethostbyname");
		getchar();
		return 1;
	}

	struct sockaddr_in alvo; 
	fd = socket(AF_INET,SOCK_STREAM,0);
	if (fd != 0)
	{
		perror("socket");
		getchar();
		return 1;
	}
	alvo.sin_family = AF_INET;
	alvo.sin_port = htons(port);
	alvo.sin_addr.s_addr = (struct in_addr *)he->h_addr;
	bzero(&(alvo.sin_zero),8);

	int conexao;
	conexao = connect(fd,(struct sockaddr *) &alvo,sizeof(alvo));
	if (conexao != 0)
	{
		perror("connect");
		getchar();
		return 1;
	}
}