From a3debe29d7f24108e5ddfe5456502189a54a630d Mon Sep 17 00:00:00 2001 From: Hugo Santos Date: Mon, 30 Apr 2007 12:31:47 +0000 Subject: [PATCH] simple test multicast application. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20921 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/kits/net/Jamfile | 1 + src/tests/kits/net/multicast/Jamfile | 6 ++++ src/tests/kits/net/multicast/multicast.cpp | 41 ++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/tests/kits/net/multicast/Jamfile create mode 100644 src/tests/kits/net/multicast/multicast.cpp diff --git a/src/tests/kits/net/Jamfile b/src/tests/kits/net/Jamfile index ea7239b0ae..15579b4533 100644 --- a/src/tests/kits/net/Jamfile +++ b/src/tests/kits/net/Jamfile @@ -62,6 +62,7 @@ SEARCH on [ FGristFiles ] = [ FDirName $(HAIKU_TOP) src tests add-ons kernel file_systems fs_shell ] ; SubInclude HAIKU_TOP src tests kits net DialUpPreflet ; +SubInclude HAIKU_TOP src tests kits net multicast ; SubInclude HAIKU_TOP src tests kits net netperf ; # SubInclude HAIKU_TOP src tests kits net new_stack ; SubInclude HAIKU_TOP src tests kits net preflet ; diff --git a/src/tests/kits/net/multicast/Jamfile b/src/tests/kits/net/multicast/Jamfile new file mode 100644 index 0000000000..5f3ad63279 --- /dev/null +++ b/src/tests/kits/net/multicast/Jamfile @@ -0,0 +1,6 @@ +SubDir HAIKU_TOP src tests kits net multicast ; + +BinCommand multicast : + multicast.cpp + : libnetwork.so +; diff --git a/src/tests/kits/net/multicast/multicast.cpp b/src/tests/kits/net/multicast/multicast.cpp new file mode 100644 index 0000000000..829a9e53c5 --- /dev/null +++ b/src/tests/kits/net/multicast/multicast.cpp @@ -0,0 +1,41 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Hugo Santos, hugosantos@gmail.com + */ + +#include + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + char buf[256]; + + int sock = socket(AF_INET, SOCK_DGRAM, 0); + + sockaddr_in sin; + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_port = htons(12345); + + bind(sock, (sockaddr *)&sin, sizeof(sin)); + + ip_mreq mreq; + memset(&mreq, 0, sizeof(mreq)); + + inet_pton(AF_INET, argv[1], &mreq.imr_multiaddr); + + setsockopt(sock, AF_INET, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)); + + while (1) { + int len = recv(sock, buf, sizeof(buf), 0); + } + + return 0; +} +