Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
38a859b8
Commit
38a859b8
authored
Jun 10, 2021
by
Pavel Vainerman
Committed by
Pavel Vainerman
Jun 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[unet-multicast]: added 'setLoopback' function
parent
b9411d81
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
1 deletion
+34
-1
MulticastTransport.cc
extensions/UNetUDP/MulticastTransport.cc
+12
-0
MulticastTransport.h
extensions/UNetUDP/MulticastTransport.h
+2
-0
unet-multicast-tester.cc
extensions/UNetUDP/unet-multicast-tester.cc
+16
-1
UDPCore.h
include/UDPCore.h
+4
-0
No files found.
extensions/UNetUDP/MulticastTransport.cc
View file @
38a859b8
...
...
@@ -227,6 +227,12 @@ std::vector<Poco::Net::IPAddress> MulticastReceiveTransport::getGroups()
{
return
groups
;
}
// -------------------------------------------------------------------------
void
MulticastReceiveTransport
::
setLoopBack
(
bool
state
)
{
if
(
udp
)
udp
->
setLoopback
(
state
);
}
// -------------------------------------------------------------------------
/*
...
...
@@ -346,6 +352,12 @@ void MulticastSendTransport::setTimeToLive( int _ttl )
udp
->
setTimeToLive
(
_ttl
);
}
// -------------------------------------------------------------------------
void
MulticastSendTransport
::
setLoopBack
(
bool
state
)
{
if
(
udp
)
udp
->
setLoopback
(
state
);
}
// -------------------------------------------------------------------------
bool
MulticastSendTransport
::
createConnection
(
bool
throwEx
,
timeout_t
sendTimeout
)
{
try
...
...
extensions/UNetUDP/MulticastTransport.h
View file @
38a859b8
...
...
@@ -45,6 +45,7 @@ namespace uniset
virtual
void
disconnect
()
override
;
virtual
int
getSocket
()
const
override
;
std
::
vector
<
Poco
::
Net
::
IPAddress
>
getGroups
();
void
setLoopBack
(
bool
state
);
bool
isReadyForReceive
(
timeout_t
tout
)
override
;
virtual
ssize_t
receive
(
void
*
r_buf
,
size_t
sz
)
override
;
...
...
@@ -78,6 +79,7 @@ namespace uniset
virtual
ssize_t
send
(
const
void
*
buf
,
size_t
sz
)
override
;
void
setTimeToLive
(
int
ttl
);
void
setLoopBack
(
bool
state
);
protected
:
std
::
unique_ptr
<
MulticastSocketU
>
udp
;
...
...
extensions/UNetUDP/unet-multicast-tester.cc
View file @
38a859b8
...
...
@@ -30,6 +30,7 @@ static struct option longopts[] =
{
"a-data"
,
required_argument
,
0
,
'a'
},
{
"d-data"
,
required_argument
,
0
,
'i'
},
{
"group"
,
required_argument
,
0
,
'g'
},
{
"loopback"
,
no_argument
,
0
,
'b'
},
{
NULL
,
0
,
0
,
0
}
};
// --------------------------------------------------------------------------
...
...
@@ -80,10 +81,11 @@ int main(int argc, char* argv[])
std
::
string
d_data
=
""
;
std
::
string
a_data
=
""
;
std
::
vector
<
Poco
::
Net
::
IPAddress
>
groups
;
bool
loopback
=
false
;
while
(
1
)
{
opt
=
getopt_long
(
argc
,
argv
,
"hs:c:r:p:n:t:x:blvdz:y:a:i:g:"
,
longopts
,
&
optindex
);
opt
=
getopt_long
(
argc
,
argv
,
"h
b
s:c:r:p:n:t:x:blvdz:y:a:i:g:"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
break
;
...
...
@@ -96,6 +98,7 @@ int main(int argc, char* argv[])
cout
<<
"[-c|--data-count] num - Send num count of value. Default: 50."
<<
endl
;
cout
<<
"[-r|--receive] host:port - Receive message."
<<
endl
;
cout
<<
"[-g|--group] ip - Multicast group address (can be specified many times)"
<<
endl
;
cout
<<
"[-b|--loopback] - Enable multicast loopback."
<<
endl
;
cout
<<
"[-p|--proc-id] id - Set packet header. From 'procID'. Default: 1"
<<
endl
;
cout
<<
"[-n|--node-id] id - Set packet header. From 'nodeID'. Default: 1"
<<
endl
;
cout
<<
"[-t|--timeout] msec - timeout for receive. Default: 0 msec (waitup)."
<<
endl
;
...
...
@@ -132,6 +135,10 @@ int main(int argc, char* argv[])
tout
=
atoi
(
optarg
);
break
;
case
'b'
:
loopback
=
true
;
break
;
case
'x'
:
usecpause
=
atoi
(
optarg
)
*
1000
;
break
;
...
...
@@ -230,6 +237,14 @@ int main(int argc, char* argv[])
udp
.
createConnection
(
true
,
500
,
true
);
if
(
loopback
)
udp
.
setLoopBack
(
true
);
msleep
(
5000
);
udp
.
disconnect
();
return
0
;
UniSetUDP
::
UDPMessage
pack
;
UniSetUDP
::
UDPPacket
buf
;
unsigned
long
prev_num
=
1
;
...
...
include/UDPCore.h
View file @
38a859b8
...
...
@@ -62,6 +62,10 @@ namespace uniset
Poco
::
Net
::
MulticastSocket
(
Poco
::
Net
::
IPAddress
::
IPv4
)
{}
MulticastSocketU
(
int
port
)
:
Poco
::
Net
::
MulticastSocket
(
Poco
::
Net
::
SocketAddress
(
Poco
::
Net
::
IPAddress
(),
port
),
true
)
{}
MulticastSocketU
(
const
std
::
string
&
bind
,
int
port
)
:
Poco
::
Net
::
MulticastSocket
(
Poco
::
Net
::
SocketAddress
(
bind
,
port
),
true
)
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment