Commit 46e14818 authored by legoc's avatar legoc

Added openport program to test a port unavailable

parent 0204a709
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
......
/*
* 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment