All pastes #1273 Raw Edit

udp bounce 2

public c v1 · immutable
#1273 ·published 2004-10-05 18:08 UTC
rendered paste body
#include <sys/socket.h>#include <sys/types.h>#include <netinet/in.h>#include <sys/time.h>int sock;int main(void) {    struct sockaddr_in sa;    int len = sizeof(sa);    int tos = 184;    pthread_t receiver, sender;        memset(&sa, 0, sizeof(sa));        sock = socket(PF_INET, SOCK_DGRAM, 0);    setsockopt(sock, SOL_SOCKET, SO_PRIORITY, &tos, sizeof(tos));    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");    }}