|
Hey. I've been trying to get this thing to work for a while, and finally managed to be able to connect to the server, but now I can't seem to join a channel. Any help would be great. Thanks =]
[code] #include <stdlib.h> #include <stdio.h> #include <netdb.h> #include <sys/socket.h> #include <netinet/in.h> #include <sys/types.h> #include <unistd.h> #include <errno.h>
void fail(char *bleh) { perror(bleh); exit(-1); }
int main() {
int sent; int get; int fd; char buf[513]; struct hostent *he; struct sockaddr_in theaddr; char nick[]="NICK TheBot\r\n"; char real[]="REALNAME TheBot\r\n"; char ident[]="IDENT meep\r\n"; char j[]="JOIN #smack\r\n";
if((he = gethostbyname("mofo.planet-sec.org")) == NULL) herror("gethostbyname");
if((fd = socket(PF_INET, SOCK_STREAM, 0)) == -1) fail("socket");
theaddr.sin_family = AF_INET; theaddr.sin_port = htons(6667); theaddr.sin_addr = *((struct in_addr *)he->h_addr); memset(theaddr.sin_zero, '\0', sizeof(theaddr.sin_zero));
if(connect(fd, (struct sockaddr *)&theaddr, sizeof(theaddr)) == -1) fail("connect");
printf("connected!\n"); sent = send(fd, nick, strlen(nick), 0); sent = send(fd, real, strlen(real), 0); sent = send(fd, ident, strlen(ident), 0); sent = send(fd, j, strlen(j), 0); printf("Joined Channel\n"); return 0;
}
This post has been edited by RapidShark: 13 Mar, 2008 - 05:04 AM
|