From 9a4263e499b328a6943e75d97358933597d390cb Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 16 Oct 2012 18:45:39 +0000 Subject: converted OSCx to the Library Template and bumped the version to 0.3.1 svn path=/branches/pd-extended/0.43/externals/oscx/; revision=16399 --- send+dump/dumpUDP.c | 190 ---------------------------------------------------- 1 file changed, 190 deletions(-) delete mode 100644 send+dump/dumpUDP.c (limited to 'send+dump/dumpUDP.c') diff --git a/send+dump/dumpUDP.c b/send+dump/dumpUDP.c deleted file mode 100644 index 494a6e3..0000000 --- a/send+dump/dumpUDP.c +++ /dev/null @@ -1,190 +0,0 @@ -/* -Written by Matt Wright, The Center for New Music and -Audio Technologies, University of California, Berkeley. Copyright (c) -1998,99,2000,01,02,03,04 The Regents of the University of -California (Regents). - -Permission to use, copy, modify, distribute, and distribute modified versions -of this software and its documentation without fee and without a signed -licensing agreement, is hereby granted, provided that the above copyright -notice, this paragraph and the following two paragraphs appear in all copies, -modifications, and distributions. - -IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, -SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING -OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS -BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED -HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE -MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - - -The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl - -dumpUDP.c: smallest UDP receiving application -by Matt Wright, 9/9/98 - -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -typedef struct ClientAddressStruct { - struct sockaddr_in cl_addr; - int clilen; - int sockfd; -} *ClientAddr; - -void PrintClientAddr(ClientAddr CA) { - unsigned long addr = CA->cl_addr.sin_addr.s_addr; - printf("Client address %p:\n", CA); - printf(" clilen %d, sockfd %d\n", CA->clilen, CA->sockfd); - printf(" sin_family %d, sin_port %d\n", CA->cl_addr.sin_family, - CA->cl_addr.sin_port); - printf(" address: (%x) %s\n", addr, inet_ntoa(CA->cl_addr.sin_addr)); - - printf(" sin_zero = \"%c%c%c%c%c%c%c%c\"\n", - CA->cl_addr.sin_zero[0], - CA->cl_addr.sin_zero[1], - CA->cl_addr.sin_zero[2], - CA->cl_addr.sin_zero[3], - CA->cl_addr.sin_zero[4], - CA->cl_addr.sin_zero[5], - CA->cl_addr.sin_zero[6], - CA->cl_addr.sin_zero[7]); - - printf("\n"); -} - - -static int initudp(int port) { - struct sockaddr_in serv_addr; - int n, sockfd; - - if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - return sockfd; - bzero((char *)&serv_addr, sizeof(serv_addr)); - serv_addr.sin_family = AF_INET; - serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); - serv_addr.sin_port = htons(port); - - if(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) - { - perror("unable to bind\n"); - return -1; - } - - fcntl(sockfd, F_SETFL, FNDELAY); - return sockfd; -} - - -static void closeudp(int sockfd) { - close(sockfd); -} - - -static int time_to_quit; - -static void catch_sigint() { - time_to_quit = 1; -} - -void GotAPacket(char *buf, int n, ClientAddr returnAddr) { - printf("received UDP packet of length %d\n", n); - PrintClientAddr(returnAddr); -} - -#define MAXMESG 32768 -static char mbuf[MAXMESG]; - -void ReceivePacket(int sockfd) { - struct ClientAddressStruct returnAddress; - int maxclilen=sizeof(returnAddress.cl_addr); - int n; - - returnAddress.clilen = maxclilen; - while( (n = recvfrom(sockfd, mbuf, MAXMESG, 0, &(returnAddress.cl_addr), - &(returnAddress.clilen))) >0) { - GotAPacket(mbuf, n, &returnAddress); - - if (time_to_quit) return; - returnAddress.clilen = maxclilen; - } -} - -void main(int argc, char **argv) { - int udp_port; /* port to receive parameter updates from */ - int sockfd; - int i; - - fd_set read_fds, write_fds; - int nfds; - - udp_port = 7000; - - sockfd=initudp(udp_port); - - if(sockfd<0) { - perror("initudp"); - return; - } - - nfds = sockfd + 1; - - time_to_quit = 0; - sigset(SIGINT, catch_sigint); /* set sig handler */ - - while(!time_to_quit) - { - - int c,r; - - back: - - FD_ZERO(&read_fds); /* clear read_fds */ - FD_ZERO(&write_fds); /* clear write_fds */ - FD_SET(sockfd, &read_fds); - - - r = select(nfds, &read_fds, &write_fds, (fd_set *)0, - (struct timeval *)0); - if (r < 0) /* select reported an error */ - goto out; - - if(FD_ISSET(sockfd, &read_fds)) { - ReceivePacket(sockfd); - } - - } /* End of while(!time_to_quit) */ -out: ; -} -- cgit v1.2.1