Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
cameo-tests
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Cameo
cameo-tests
Commits
46e14818
Commit
46e14818
authored
Oct 21, 2020
by
legoc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added openport program to test a port unavailable
parent
0204a709
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
0 deletions
+63
-0
src/Makefile.am
src/Makefile.am
+8
-0
src/OpenPort.cpp
src/OpenPort.cpp
+55
-0
No files found.
src/Makefile.am
View file @
46e14818
INCLUDES
=
-I
$(top_srcdir)
/src
bin_PROGRAMS
=
\
openport
\
testcameo
\
testveryfast
\
testsimple
\
...
...
@@ -44,6 +45,13 @@ bin_PROGRAMS = \
testcomport
\
teststartcomport
openport_SOURCES
=
\
OpenPort.cpp
openport_CPPFLAGS
=
$(CT_CXXFLAGS)
openport_LDFLAGS
=
$(CT_LDFLAGS)
openport_LDADD
=
$(CT_LIBS)
testcameo_SOURCES
=
\
Test.cpp
...
...
src/OpenPort.cpp
0 → 100644
View file @
46e14818
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "zmq.hpp"
#include <iostream>
using
namespace
std
;
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
<
3
)
{
cout
<<
"usage: <port>"
<<
endl
;
return
1
;
}
string
port
(
argv
[
1
]);
zmq
::
context_t
context
(
1
);
zmq
::
socket_t
socket
(
context
,
ZMQ_REP
);
string
endpoint
(
"tcp://*:"
);
endpoint
+=
port
;
cout
<<
"trying to bind "
<<
endpoint
<<
endl
;
try
{
socket
.
bind
(
endpoint
.
c_str
());
}
catch
(
const
exception
&
e
)
{
cout
<<
"cannot bind port: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"bound port "
<<
port
<<
endl
;
int
c
;
cin
>>
c
;
return
0
;
}
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