forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMulticastSocketTest.cpp
More file actions
84 lines (62 loc) · 1.62 KB
/
MulticastSocketTest.cpp
File metadata and controls
84 lines (62 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// MulticastSocketTest.cpp
//
// $Id: //poco/1.4/Net/testsuite/src/MulticastSocketTest.cpp#1 $
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "MulticastSocketTest.h"
#ifdef POCO_NET_HAS_INTERFACE
#include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h"
#include "MulticastEchoServer.h"
#include "Poco/Net/MulticastSocket.h"
#include "Poco/Net/SocketAddress.h"
#include "Poco/Net/NetException.h"
#include "Poco/Timespan.h"
#include "Poco/Stopwatch.h"
using Poco::Net::Socket;
using Poco::Net::MulticastSocket;
using Poco::Net::SocketAddress;
using Poco::Net::IPAddress;
using Poco::Timespan;
using Poco::Stopwatch;
using Poco::TimeoutException;
using Poco::InvalidArgumentException;
using Poco::IOException;
MulticastSocketTest::MulticastSocketTest(const std::string& name): CppUnit::TestCase(name)
{
}
MulticastSocketTest::~MulticastSocketTest()
{
}
void MulticastSocketTest::testMulticast()
{
MulticastEchoServer echoServer;
MulticastSocket ms;
int n = ms.sendTo("hello", 5, echoServer.group());
assert (n == 5);
char buffer[256];
n = ms.receiveBytes(buffer, sizeof(buffer));
assert (n == 5);
assert (std::string(buffer, n) == "hello");
ms.close();
}
void MulticastSocketTest::setUp()
{
}
void MulticastSocketTest::tearDown()
{
}
CppUnit::Test* MulticastSocketTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MulticastSocketTest");
#if (POCO_OS != POCO_OS_FREE_BSD) // TODO
CppUnit_addTest(pSuite, MulticastSocketTest, testMulticast);
#endif
return pSuite;
}
#endif // POCO_NET_HAS_INTERFACE