Catch errors.
This commit is contained in:
23
src/node.cpp
23
src/node.cpp
@ -24,18 +24,35 @@
|
||||
#include <opendht.h>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
||||
extern "C" {
|
||||
#include <gnutls/gnutls.h>
|
||||
}
|
||||
|
||||
#define DEFAULT_PORT 1335
|
||||
|
||||
dht::DhtRunner node;
|
||||
|
||||
void NeoComm_init(const unsigned short port) {
|
||||
node.run((port == 0 ? DEFAULT_PORT : port),
|
||||
dht::crypto::generateIdentity(), true);
|
||||
int NeoComm_init(const unsigned short port) {
|
||||
#ifdef WOE32
|
||||
gnutls_global_init();
|
||||
#endif //WOE32
|
||||
try {
|
||||
node.run((port == 0 ? DEFAULT_PORT : port),
|
||||
dht::crypto::generateIdentity(), true);
|
||||
} catch(const std::exception &e) {
|
||||
add_error(e.what());
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void NeoComm_deinit() {
|
||||
node.join();
|
||||
#ifdef WOE32
|
||||
gnutls_global_deinit();
|
||||
#endif //WOE32
|
||||
}
|
||||
|
||||
int NeoComm_connect(const char *address, const unsigned short port) {
|
||||
|
Reference in New Issue
Block a user