All pastes #397507 Raw Edit

Stuff

public c v1 · immutable
·published 2007-03-16 15:24 UTC
rendered paste body
#include <string.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#define DEST_IP   "72.20.46.119"#define DEST_PORT 6667main(){    int sockfd;    char buffer[1024];    struct sockaddr_in dest_addr;   // will hold the destination addr    sockfd = socket(AF_INET, SOCK_STREAM, 0); // do some error checking!    dest_addr.sin_family = AF_INET;          // host byte order    dest_addr.sin_port = htons(DEST_PORT);   // short, network byte order    dest_addr.sin_addr.s_addr = inet_addr(DEST_IP);    memset(&(dest_addr.sin_zero), '\0', 8);  // zero the rest of the struct    // don't forget to error check the connect()!    connect(sockfd, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr));    send(sockfd, "USER Botti localhost localhost :Botti", 1024, 0);    send(sockfd, "NICK Botti", 1024, 0);    send(sockfd, "JOIN #testaus", 1024, 0);    while(1)    recv(sockfd, buffer, 1024, 0);    return 0;}