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
d7dcf8bd
Commit
d7dcf8bd
authored
Dec 14, 2010
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
попытка встроить в udp номер пакета
parent
312ddd32
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
6 deletions
+44
-6
UDPExchange.cc
extensions/UDPExchange/UDPExchange.cc
+36
-3
UDPExchange.h
extensions/UDPExchange/UDPExchange.h
+4
-0
UDPNReceiver.cc
extensions/UDPExchange/UDPNReceiver.cc
+1
-1
UDPPacket.h
extensions/UDPExchange/UDPPacket.h
+1
-0
start_fg.sh
extensions/UDPExchange/start_fg.sh
+2
-2
No files found.
extensions/UDPExchange/UDPExchange.cc
View file @
d7dcf8bd
...
...
@@ -14,7 +14,8 @@ initPause(0),
udp
(
0
),
activated
(
false
),
dlist
(
100
),
maxItem
(
0
)
maxItem
(
0
),
packetnum
(
1
)
{
if
(
objId
==
DefaultObjectId
)
throw
UniSetTypes
::
SystemError
(
"(UDPExchange): objId=-1?!! Use --udp-name"
);
...
...
@@ -224,11 +225,43 @@ void UDPExchange::poll()
void
UDPExchange
::
send
()
{
cout
<<
myname
<<
": send..."
<<
endl
;
/*
UniSetUDP
::
UDPHeader
h
;
h
.
nodeID
=
conf
->
getLocalNode
();
h
.
procID
=
getId
();
h
.
dcount
=
mypack
.
size
();
h
.
num
=
packetnum
++
;
int
ind
=
0
;
memcpy
(
udpbuf
,(
char
*
)(
&
h
),
sizeof
(
h
));
ind
+=
sizeof
(
h
);
UniSetUDP
::
UDPMessage
::
UDPDataList
::
iterator
it
=
mypack
.
dlist
.
begin
();
for
(
;
it
!=
mypack
.
dlist
.
end
();
++
it
)
{
memcpy
(
&
(
udpbuf
[
ind
]),
&
(
*
it
),
sizeof
(
UniSetUDP
::
UDPData
));
ind
+=
sizeof
(
UniSetUDP
::
UDPData
);
if
(
ind
>=
MaxDataLen
)
{
cerr
<<
myname
<<
"(send data): data len > "
<<
MaxDataLen
<<
"!!!!"
<<
endl
;
return
;
}
}
if
(
udp
->
isPending
(
ost
::
Socket
::
pendingOutput
)
)
{
ssize_t
ret
=
udp
->
send
(
udpbuf
,
ind
);
if
(
ret
<
(
ssize_t
)
ind
)
{
cerr
<<
myname
<<
"(send data header): ret="
<<
ret
<<
" byte count="
<<
ind
<<
endl
;
return
;
}
cout
<<
"send OK. byte count="
<<
ret
<<
endl
;
}
#if 0
/*
if( udp->isPending(ost::Socket::pendingOutput) )
{
ssize_t ret = udp->send((char*)(&h),sizeof(h));
...
...
@@ -245,7 +278,6 @@ void UDPExchange::send()
{
// while( !udp->isPending(ost::Socket::pendingOutput) )
// msleep(30);
cout << myname << "(send): " << (*it) << endl;
ssize_t ret = udp->send((char*)(&(*it)),sizeof(UniSetUDP::UDPData));
if( ret<(ssize_t)sizeof(UniSetUDP::UDPData) )
...
...
@@ -255,6 +287,7 @@ void UDPExchange::send()
}
}
// }
#endif
}
// -----------------------------------------------------------------------------
void
UDPExchange
::
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
)
...
...
extensions/UDPExchange/UDPExchange.h
View file @
d7dcf8bd
...
...
@@ -113,6 +113,10 @@ class UDPExchange:
ReceiverList
rlist
;
ThreadCreator
<
UDPExchange
>*
thr
;
static
const
int
MaxDataLen
=
8192
;
char
udpbuf
[
MaxDataLen
];
long
packetnum
;
};
// -----------------------------------------------------------------------------
#endif // UDPExchange_H_
...
...
extensions/UDPExchange/UDPNReceiver.cc
View file @
d7dcf8bd
...
...
@@ -117,7 +117,7 @@ void UDPNReceiver::recv()
return;
}
#endif
cout
<<
"***** request: "
<<
udp
->
UDPSocket
::
getIPV4Peer
()
<<
endl
;
//
cout << "***** request: " << udp->UDPSocket::getIPV4Peer() << endl;
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
ssize_t
ret
=
udp
->
UDPReceive
::
receive
(
&
d
,
sizeof
(
d
));
...
...
extensions/UDPExchange/UDPPacket.h
View file @
d7dcf8bd
...
...
@@ -11,6 +11,7 @@ namespace UniSetUDP
{
struct
UDPHeader
{
long
num
;
long
nodeID
;
long
procID
;
long
dcount
;
...
...
extensions/UDPExchange/start_fg.sh
View file @
d7dcf8bd
#!/bin/sh
uniset-start.sh
-f
./uniset-udpexchange
--udp-name
UDPExchange
--udp-host
192.168.
56
.255
\
--udp-broadcast
1
--udp-polltime
100
0
\
uniset-start.sh
-f
./uniset-udpexchange
--udp-name
UDPExchange
--udp-host
192.168.
1
.255
\
--udp-broadcast
1
--udp-polltime
100
\
--confile
test.xml
\
--dlog-add-levels
info,crit,warn
# --udp-filter-field udp --udp-filter-value 1 \
...
...
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