All pastes #1205 Raw Edit

udpbounce2

public c v1 · immutable
#1205 ·published 2004-10-02 08:31 UTC
rendered paste body
#include <sys/socket.h>#include <sys/types.h>#include <netinet/in.h>#include <pthread.h>#include <sys/time.h>int sock;int main(void) {    struct sockaddr_in sa;    int len = sizeof(sa);    pthread_t receiver, sender;        memset(&sa, 0, sizeof(sa));        sock = socket(PF_INET, SOCK_DGRAM, 0);    sa.sin_port = htons(12388);    sa.sin_family = PF_INET;    bind(sock, (struct sockaddr *)&sa, len);        while(1) {        char buf[32];        int r;        r = recvfrom(sock, buf, 32, 0, (struct sockaddr *)&sa, &len);        if(sendto(sock, buf, r, 0, (struct sockaddr *)&sa, len) == -1)            perror("sendto");    }}