Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
ITADataSources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
ITADataSources
Commits
825795a2
Commit
825795a2
authored
Jan 20, 2017
by
Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aktueller stand netzwerkproblem
parent
219f28be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
63 deletions
+74
-63
src/ITANetAudioMessage.cpp
src/ITANetAudioMessage.cpp
+1
-1
tests/VistaNetTest/VistaNetTest.cpp
tests/VistaNetTest/VistaNetTest.cpp
+73
-62
No files found.
src/ITANetAudioMessage.cpp
View file @
825795a2
...
...
@@ -88,7 +88,7 @@ void CITANetAudioMessage::WriteMessage()
std
::
cout
<<
"CITANetAudioMessage [ Writing] "
<<
m_nMessageType
<<
" (id="
<<
std
::
setw
(
4
)
<<
m_nMessageId
<<
")"
<<
std
::
endl
;
#endif
//
try
try
{
int
iRawBufferSize
=
m_oOutgoing
.
GetBufferSize
();
int
nRet
=
m_pConnection
->
Send
(
m_oOutgoing
.
GetBuffer
(),
iRawBufferSize
);
...
...
tests/VistaNetTest/VistaNetTest.cpp
View file @
825795a2
#include <cassert>
#include <iostream>
#include <string>
#include <VistaInterProcComm/Concurrency/VistaThread
Loop
.h>
#include <VistaInterProcComm/Concurrency/VistaThread.h>
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
#include <VistaInterProcComm/IPNet/VistaTCPServer.h>
#include <VistaInterProcComm/IPNet/VistaTCPSocket.h>
#include <VistaBase/Vista
Time
Utils.h>
#include <VistaBase/Vista
Stream
Utils.h>
using
namespace
std
;
static
string
g_sServerName
=
"localhost"
;
static
int
g_iServerPort
=
12480
;
static
int
g_iRepetitions
=
10
;
class
CServer
:
public
VistaThread
Loop
class
CServer
:
public
VistaThread
{
public:
CServer
()
{
m_pServer
=
new
VistaTCPServer
(
g_sServerName
,
g_iServerPort
,
1
);
Run
();
}
}
;
~
CServer
()
{
delete
m_pServer
;
}
}
;
bool
Loop
Body
()
void
Thread
Body
()
{
cout
<<
"[ Server ] Waiting for connections"
<<
endl
;
VistaTCPSocket
*
pSocket
=
m_pServer
->
GetNextClient
();
VistaTimeUtils
::
Sleep
(
100
);
// Sync couts
cout
<<
"[ Server ] Connected."
<<
endl
;
vstr
::
out
()
<<
"[ Server ] Connected."
<<
endl
;
size_t
nGetReceiveBufferSize
=
pSocket
->
GetReceiveBufferSize
();
cout
<<
"[ Server ] "
<<
nGetReceiveBufferSize
<<
" receive buffer size"
<<
endl
;
long
nIncomingBytes
=
pSocket
->
WaitForIncomingData
(
0
);
cout
<<
"[ Server ] "
<<
nIncomingBytes
<<
" incoming bytes"
<<
endl
;
vstr
::
out
()
<<
"[ Server ] "
<<
nGetReceiveBufferSize
<<
" receive buffer size"
<<
endl
;
// Two-step receiving
int
iPayloadDataSize
;
int
iIncomingBytes
=
pSocket
->
ReceiveRaw
(
&
iPayloadDataSize
,
sizeof
(
int
)
);
cout
<<
"[ Server ] Expecting "
<<
iPayloadDataSize
<<
" bytes to come."
<<
endl
;
vector
<
char
>
vdIncomingData
(
iPayloadDataSize
);
int
iBytesReceivedTotal
=
pSocket
->
ReceiveRaw
(
&
vdIncomingData
[
0
],
iPayloadDataSize
);
cout
<<
"[ Server ] Received "
<<
iBytesReceivedTotal
<<
" bytes, so far."
<<
endl
;
vector
<
char
>
vdIncomingData
;
while
(
iPayloadDataSize
!=
iBytesReceivedTotal
)
bool
bRepeat
=
true
;
while
(
bRepeat
)
{
int
iBytesReceived
=
pSocket
->
ReceiveRaw
(
&
vdIncomingData
[
iBytesReceivedTotal
],
iPayloadDataSize
);
iBytesReceivedTotal
+=
iBytesReceived
;
cout
<<
"[ Server ] Further "
<<
iBytesReceived
<<
" bytes incoming"
<<
endl
;
long
nIncomingBytes
=
pSocket
->
WaitForIncomingData
(
0
);
vstr
::
out
()
<<
"[ Server ] "
<<
nIncomingBytes
<<
" incoming bytes"
<<
endl
;
// Two-step receiving
int
iPayloadDataSize
;
int
iBytesRead
=
pSocket
->
ReceiveRaw
(
&
iPayloadDataSize
,
sizeof
(
int
)
);
assert
(
iBytesRead
==
sizeof
(
int
)
);
vstr
::
out
()
<<
"[ Server ] Expecting "
<<
iPayloadDataSize
<<
" bytes to come."
<<
endl
;
if
(
iPayloadDataSize
>
vdIncomingData
.
size
()
)
vdIncomingData
.
resize
(
iPayloadDataSize
);
int
iBytesReceivedTotal
=
0
;
while
(
iPayloadDataSize
!=
iBytesReceivedTotal
)
{
int
iBytesReceived
=
pSocket
->
ReceiveRaw
(
&
vdIncomingData
[
iBytesReceivedTotal
],
iPayloadDataSize
);
iBytesReceivedTotal
+=
iBytesReceived
;
vstr
::
out
()
<<
"[ Server ] "
<<
setw
(
3
)
<<
std
::
floor
(
iBytesReceivedTotal
/
float
(
iPayloadDataSize
)
*
100.0
f
)
<<
"% transmitted"
<<
endl
;
}
assert
(
vdIncomingData
[
0
]
==
1
);
assert
(
vdIncomingData
[
vdIncomingData
.
size
()
-
2
]
==
-
1
);
vstr
::
out
()
<<
"[ Server ] Received all data and content appears valid!"
<<
endl
;
vstr
::
out
()
<<
"[ Server ] Sending acknowledge flag"
<<
endl
;
bool
bTransmissionDone
=
true
;
pSocket
->
SendRaw
(
&
bTransmissionDone
,
sizeof
(
bool
)
);
iBytesRead
=
pSocket
->
ReceiveRaw
(
&
bRepeat
,
sizeof
(
bool
)
);
if
(
bRepeat
)
vstr
::
out
()
<<
"[ Server ] Repeating"
<<
endl
;
}
assert
(
vdIncomingData
[
0
]
==
1
);
assert
(
vdIncomingData
[
vdIncomingData
.
size
()
-
2
]
==
-
1
);
cout
<<
"[ Server ] Received all data and content appears valid!"
<<
endl
;
VistaTimeUtils
::
Sleep
(
200
);
cout
<<
"[ Server ] Sending acknowledge flag"
<<
endl
;
bool
bAck
=
false
;
pSocket
->
SendRaw
(
&
bAck
,
1
);
return
false
;
}
vstr
::
out
()
<<
"[ Server ] Closing."
<<
endl
;
};
private:
VistaTCPServer
*
m_pServer
;
...
...
@@ -78,38 +85,42 @@ private:
int
main
(
int
,
char
**
)
{
CServer
oServer
;
VistaTimeUtils
::
Sleep
(
100
);
// Sync couts
VistaConnectionIP
oConnection
(
VistaConnectionIP
::
CT_TCP
,
g_sServerName
,
g_iServerPort
);
if
(
!
oConnection
.
GetIsConnected
()
)
{
cerr
<<
"[ Client ] Connection failed"
<<
endl
;
vstr
::
out
()
<<
"[ Client ] Connection failed"
<<
endl
;
return
255
;
}
cout
<<
"[ Client ] Connection established"
<<
endl
;
VistaTimeUtils
::
Sleep
(
500
);
cout
<<
"[ Client ] Client sending data"
<<
endl
;
VistaTimeUtils
::
Sleep
(
500
);
cout
<<
"[ Client ] Connection is buffering: "
<<
(
oConnection
.
GetIsBuffering
()
?
"yes"
:
"no"
)
<<
endl
;
size_t
l
=
1523633239
;
// > MTU?
vector
<
char
>
vdData
(
l
+
4
);
int
*
piDataSize
=
(
int
*
)
&
vdData
[
0
];
*
piDataSize
=
unsigned
int
(
l
);
// Send data size as first block
vdData
[
1
*
sizeof
(
int
)
+
0
]
=
1
;
// First entry one (just for fun)
vdData
[
vdData
.
size
()
-
2
]
=
-
1
;
// Second last entry -1 (just for fun)
void
*
pData
=
(
void
*
)
&
vdData
[
0
];
oConnection
.
Send
(
pData
,
int
(
vdData
.
size
()
)
);
// SendRaw?
vstr
::
out
()
<<
"[ Client ] Connection established"
<<
endl
;
vstr
::
out
()
<<
"[ Client ] Connection is buffering: "
<<
(
oConnection
.
GetIsBuffering
()
?
"yes"
:
"no"
)
<<
endl
;
bool
bAck
;
oConnection
.
ReadBool
(
bAck
);
VistaTimeUtils
::
Sleep
(
100
);
// cout sync
cout
<<
"[ Client ] Received acknowledge flag '"
<<
bAck
<<
"', closing."
<<
endl
;
int
i
=
0
;
while
(
i
++
<=
g_iRepetitions
)
{
vstr
::
out
()
<<
"[ Client ] Client sending data now."
<<
endl
;
size_t
l
=
1523633239
;
// > MTU?
vector
<
char
>
vdData
(
l
+
4
);
int
*
piDataSize
=
(
int
*
)
&
vdData
[
0
];
*
piDataSize
=
unsigned
int
(
l
);
// Send data size as first block
vdData
[
1
*
sizeof
(
int
)
+
0
]
=
1
;
// First entry one (just for fun)
vdData
[
vdData
.
size
()
-
2
]
=
-
1
;
// Second last entry -1 (just for fun)
void
*
pData
=
(
void
*
)
&
vdData
[
0
];
oConnection
.
Send
(
pData
,
int
(
vdData
.
size
()
)
);
// SendRaw?
bool
bAck
;
oConnection
.
ReadBool
(
bAck
);
if
(
!
bAck
)
vstr
::
out
()
<<
"[ Client ] Received negative acknowledge flag"
<<
endl
;
else
vstr
::
out
()
<<
"[ Client ] Received positive acknowledge flag"
<<
endl
;
bool
bRepeat
=
(
i
<=
g_iRepetitions
);
oConnection
.
Send
(
&
bRepeat
,
sizeof
(
bool
)
);
}
oConnection
.
Close
(
false
);
...
...
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