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
23c18175
Commit
23c18175
authored
Jun 23, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил код для внутреннего тестирования обмена через UTCPSocket
parent
f98f5e49
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
114 additions
and
1 deletion
+114
-1
configure.ac
configure.ac
+1
-0
Makefile.am
tests/Makefile.am
+1
-1
Makefile.am
tests/TCPSocketTest/Makefile.am
+8
-0
bash_server.sh
tests/TCPSocketTest/bash_server.sh
+13
-0
sock-client.cc
tests/TCPSocketTest/sock-client.cc
+41
-0
sock-server.cc
tests/TCPSocketTest/sock-server.cc
+47
-0
uniset2.files
uniset2.files
+3
-0
No files found.
configure.ac
View file @
23c18175
...
...
@@ -442,6 +442,7 @@ AC_CONFIG_FILES([Makefile
tests/MQPerfTest/Makefile
tests/PocoTest/Makefile
tests/UHttpTest/Makefile
tests/TCPSocketTest/Makefile
docs/Makefile
docs/UniSetDox.cfg
docs/UniSetDoxDevel.cfg
...
...
tests/Makefile.am
View file @
23c18175
SUBDIRS
=
MQPerfTest PocoTest UHttpTest
SUBDIRS
=
MQPerfTest PocoTest UHttpTest
TCPSocketTest
if
HAVE_TESTS
############################################################################
# This file is part of the UniSet library #
...
...
tests/TCPSocketTest/Makefile.am
0 → 100644
View file @
23c18175
noinst_PROGRAMS
=
sock-client sock-server
sock_client_LDADD
=
$(top_builddir)
/lib/libUniSet2.la
$(SIGC_LIBS)
$(POCO_LIBS)
sock_client_CPPFLAGS
=
-I
$(top_builddir)
/include
-I
$(top_builddir)
/extensions/include
$(SIGC_CFLAGS)
$(POCO_CFLAGS)
sock_client_SOURCES
=
sock-client.cc
sock_server_LDADD
=
$(top_builddir)
/lib/libUniSet2.la
$(SIGC_LIBS)
$(POCO_LIBS)
sock_server_CPPFLAGS
=
-I
$(top_builddir)
/include
-I
$(top_builddir)
/extensions/include
$(SIGC_CFLAGS)
$(POCO_CFLAGS)
sock_server_SOURCES
=
sock-server.cc
tests/TCPSocketTest/bash_server.sh
0 → 100755
View file @
23c18175
#!/bin/sh
function
usage
()
{
echo
"Usage: bash_server.sh IP PORT"
exit
0
}
[
-z
"
$1
"
]
&&
usage
[
-z
"
$2
"
]
&&
usage
nc
$1
$2
-lkvD
\ No newline at end of file
tests/TCPSocketTest/sock-client.cc
0 → 100644
View file @
23c18175
#include "UTCPStream.h"
#include "UniSetTypes.h"
#include <iostream>
// --------------------------------------------------------------------------
using
namespace
std
;
// --------------------------------------------------------------------------
int
main
(
int
argc
,
const
char
**
argv
)
{
try
{
std
::
string
host
=
"localhost"
;
if
(
argc
>
1
)
host
=
std
::
string
(
argv
[
1
]);
uniset
::
UTCPStream
tcp
;
while
(
true
)
{
{
tcp
.
create
(
host
,
2048
);
std
::
string
buf
=
"1234567890.10.11.12.13.14.15.16.17.18.29.20.21ksdjcb sdjcb sldfjvbds fljvhbds jfvhbdsbvjksdbfvjdssvksdbvjsdbvjsbfjskdfbvjsdfbvjdfbvFINISH
\n
"
;
size_t
nbytes
=
tcp
.
sendBytes
(
buf
.
data
(),
buf
.
size
());
cout
<<
"real bytes: "
<<
buf
.
size
()
<<
" send: "
<<
nbytes
<<
" bytes"
<<
endl
;
tcp
.
disconnect
();
}
msleep
(
5000
);
}
return
0
;
}
catch
(
const
std
::
exception
&
e
)
{
cerr
<<
"(sock-client): "
<<
e
.
what
()
<<
endl
;
}
catch
(...)
{
cerr
<<
"(sock-client): catch(...)"
<<
endl
;
}
return
1
;
}
tests/TCPSocketTest/sock-server.cc
0 → 100644
View file @
23c18175
#include "UTCPSocket.h"
#include "Poco/Net/StreamSocket.h"
#include "Poco/Net/SocketStream.h"
#include <iostream>
// --------------------------------------------------------------------------
using
namespace
std
;
using
namespace
Poco
;
// --------------------------------------------------------------------------
int
main
(
int
argc
,
const
char
**
argv
)
{
try
{
uniset
::
UTCPSocket
sock
(
"localhost"
,
2048
);
while
(
true
)
{
Net
::
StreamSocket
ss
=
sock
.
acceptConnection
();
Poco
::
FIFOBuffer
buf
(
1000
);
if
(
ss
.
poll
(
uniset
::
UniSetTimer
::
millisecToPoco
(
5000
),
Poco
::
Net
::
Socket
::
SELECT_READ
)
)
{
int
r
=
ss
.
receiveBytes
(
buf
);
cout
<<
"recv("
<<
r
<<
"): used="
<<
buf
.
used
()
<<
" [ "
;
for
(
size_t
i
=
0
;
i
<
r
;
i
++
)
cout
<<
(
int
)
buf
[
i
];
// std::unique_ptr<char[]> data(new char[buf.used()]);
// buf.read(data.get(), r);
// cout << std::string(data.get(), r) << endl;
cout
<<
" ]"
<<
endl
;
}
}
return
0
;
}
catch
(
const
std
::
exception
&
e
)
{
cerr
<<
"(sock-server): "
<<
e
.
what
()
<<
endl
;
}
catch
(...)
{
cerr
<<
"(sock-server): catch(...)"
<<
endl
;
}
return
1
;
}
uniset2.files
View file @
23c18175
...
...
@@ -453,6 +453,9 @@ src/Various/ujson.cc
src/Makefile.am
tests/UniXmlTest/Makefile.am
tests/UniXmlTest/XmlTest.cc
tests/TCPSocketTest/sock-client.cc
tests/TCPSocketTest/sock-server.cc
tests/TCPSocketTest/Makefile.am
tests/int_unsigned.cc
tests/Makefile.am
tests/test.xml
...
...
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