simple test multicast application.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20921 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0e30c21c70
commit
a3debe29d7
@ -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 ;
|
||||
|
6
src/tests/kits/net/multicast/Jamfile
Normal file
6
src/tests/kits/net/multicast/Jamfile
Normal file
@ -0,0 +1,6 @@
|
||||
SubDir HAIKU_TOP src tests kits net multicast ;
|
||||
|
||||
BinCommand multicast :
|
||||
multicast.cpp
|
||||
: libnetwork.so
|
||||
;
|
41
src/tests/kits/net/multicast/multicast.cpp
Normal file
41
src/tests/kits/net/multicast/multicast.cpp
Normal file
@ -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 <string.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user