38 if (fallback==
nullptr) {
39 fprintf(stderr,
"Cannot allocate ServerAdapter\n");
45 if (fallback!=
nullptr)
delete fallback;
49 std::string
apply(
const std::string& txt,
const Contact& remote)
override {
59 printf(
"ASKED %s, GAVE %s\n", txt.c_str(), result.c_str());
64 return fallback->
start();
77 fprintf(stderr,
"Cannot allocate ServerAdapter\n");
82 BootstrapServer::~BootstrapServer() {
90 bool BootstrapServer::start() {
97 bool BootstrapServer::stop() {
106 bool configFileRequired,
107 bool mayEditConfigFile) {
115 }
else if (configFileRequired) {
116 fprintf(stderr,
"Could not read configuration file %s\n",
123 if (suggest.
getHost() ==
"...") {
142 if (suggest.
getHost() ==
"...") {
147 if (!configFileRequired) {
150 fprintf(stderr,
"Overriding non-local address for name server\n");
155 if (betterHost!=suggest.
getHost()) {
156 fprintf(stderr,
"Overriding loopback address for name server\n");
162 bool changed =
false;
168 if (changed && !mayEditConfigFile) {
169 fprintf(stderr,
"PROBLEM: need to change settings in %s\n",
171 fprintf(stderr,
" Current settings: host %s port %d family %s\n",
174 fprintf(stderr,
" Desired settings: host %s port %d family %s\n",
176 fprintf(stderr,
"Please specify '--write' if it is ok to overwrite current settings, or\n");
177 fprintf(stderr,
"Please specify '--read' to use the current settings, or\n");
181 bool shouldSave = changed || !prev.
isValid();
187 fprintf(stderr,
"Could not save configuration file %s\n",
198 Contact addr = FallbackNameServer::getAddress();
static void handler(int sig)
RandScalar * implementation(void *t)
Adapt YARP multicast server to use a different NameService.
BootstrapServerAdapter(NameService &owner)
virtual ~BootstrapServerAdapter()
std::string apply(const std::string &txt, const Contact &remote) override
Manage a single connection to the name server.
Abstract interface for a name server operator.
virtual std::string expectText(const char terminatingChar='\n')=0
Read some text from the network connection.
An interface for writing to a network connection.
virtual void appendText(const std::string &str, const char terminate='\n')=0
Send a terminated string to the network connection.
A dummy connection to test yarp::os::Portable implementations.
ConnectionWriter & getWriter()
Get the dummy ConnectionWriter loaded with whatever was written the ConnectionWriter since it was las...
void setTextMode(bool textmode)
Set the textMode of the dummy connection.
ConnectionReader & getReader()
Get the dummy ConnectionReader loaded with whatever was written the ConnectionWriter since it was las...
Multi-cast server, for last resort information sharing about name information – when config files are...
Small helper class to help deal with legacy YARP configuration files.
std::string getNamespace(bool refresh=false)
static std::string getHostName(bool prefer_loopback=false, const std::string &seed="")
static bool isLocalName(const std::string &name)
bool fromFile(const char *ns=nullptr)
std::string getConfigFileName(const char *stem=nullptr, const char *ns=nullptr)
void setAddress(const Contact &address)
bool toFile(bool clean=false)
Stub for a YARP2-conforming name server.
Classes for constructing name servers.
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.