1. delete some debug codes in Database.cpp, which may lead to segmentation fault.
2. update several connection classes(in Server folder) to support configurable gserver listening port.
This commit is contained in:
parent
f1d3e2c3b8
commit
6b5bf3fea5
|
@ -654,16 +654,6 @@ bool Database::literal2id_RDFintoSignature(const string _rdf_file, int** _p_id_t
|
|||
|
||||
}/* end for while(true) */
|
||||
|
||||
//debug
|
||||
{
|
||||
string debug_entity_name = "<http://www.Department6.University184.edu/Course43>";
|
||||
int debug_entity_id = (this->kvstore)->getIDByEntity(debug_entity_name);
|
||||
stringstream _ss;
|
||||
_ss << "display [" << debug_entity_name << ":" << debug_entity_id << "] bitset:" <<endl;
|
||||
_ss << Signature::BitSet2str(_entity_bitset[debug_entity_id]) << endl;
|
||||
Database::log(_ss.str());
|
||||
}
|
||||
|
||||
cout << "end for while" << endl;
|
||||
delete[] triple_array;
|
||||
_six_tuples_fout.close();
|
||||
|
|
|
@ -88,6 +88,8 @@ private:
|
|||
int pre_num;
|
||||
int literal_num;
|
||||
|
||||
string rdf_prefix;
|
||||
|
||||
int encode_mode;
|
||||
|
||||
VSTree* vstree;
|
||||
|
|
|
@ -8,6 +8,28 @@
|
|||
#include"Client.h"
|
||||
#include<iostream>
|
||||
|
||||
Client::Client()
|
||||
{
|
||||
this->ip = Socket::DEFAULT_SERVER_IP;
|
||||
this->port = Socket::DEFAULT_CONNECT_PORT;
|
||||
}
|
||||
|
||||
Client::Client(std::string _ip, unsigned short _port)
|
||||
{
|
||||
this->ip = _ip;
|
||||
this->port = _port;
|
||||
}
|
||||
|
||||
Client::Client(unsigned short _port)
|
||||
{
|
||||
this->ip = Socket::DEFAULT_SERVER_IP;
|
||||
this->port = _port;
|
||||
}
|
||||
|
||||
Client::~Client()
|
||||
{
|
||||
}
|
||||
|
||||
bool Client::connectServer()
|
||||
{
|
||||
bool flag = this->socket.create();
|
||||
|
@ -17,8 +39,7 @@ bool Client::connectServer()
|
|||
return false;
|
||||
}
|
||||
|
||||
flag = this->socket.connect("127.0.0.1", 3305);
|
||||
// flag = this->socket.connect("172.31.19.15", 3305);
|
||||
flag = this->socket.connect(this->ip, this->port);
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,11 @@
|
|||
class Client
|
||||
{
|
||||
public:
|
||||
Client();
|
||||
Client(std::string _ip, unsigned short _port);
|
||||
Client(unsigned short _port);
|
||||
~Client();
|
||||
|
||||
bool connectServer();
|
||||
bool disconnectServer();
|
||||
bool send(const std::string& _msg);
|
||||
|
|
|
@ -12,7 +12,15 @@
|
|||
|
||||
Server::Server()
|
||||
{
|
||||
this->connectionPort = 3305; // default communication port is 3305.
|
||||
this->connectionPort = Socket::DEFAULT_CONNECT_PORT; // default communication port is 3305.
|
||||
this->connectionMaxNum = Socket::MAX_CONNECTIONS;
|
||||
this->databaseMaxNum = 1; // will be updated when supporting multiple databases.
|
||||
this->database = NULL;
|
||||
}
|
||||
|
||||
Server::Server(unsigned short _port)
|
||||
{
|
||||
this->connectionPort = _port;
|
||||
this->connectionMaxNum = Socket::MAX_CONNECTIONS;
|
||||
this->databaseMaxNum = 1; // will be updated when supporting multiple databases.
|
||||
this->database = NULL;
|
||||
|
|
|
@ -31,6 +31,7 @@ class Server
|
|||
{
|
||||
public:
|
||||
Server();
|
||||
Server(unsigned short _port);
|
||||
~Server();
|
||||
|
||||
bool createConnection();
|
||||
|
@ -49,7 +50,7 @@ public:
|
|||
|
||||
|
||||
private:
|
||||
int connectionPort;
|
||||
unsigned short connectionPort;
|
||||
int connectionMaxNum;
|
||||
int databaseMaxNum;
|
||||
Socket socket;
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
const std::string Socket::DEFAULT_SERVER_IP = "127.0.0.1";
|
||||
|
||||
Socket::Socket()
|
||||
{
|
||||
this->sock = -1;
|
||||
|
@ -193,6 +195,8 @@ int Socket::recv(std::string& _msg)const
|
|||
recv_len += cur_len;
|
||||
}while (recv_len < msg_len);
|
||||
|
||||
// std::cout << "recv_len=" << recv_len << std::endl; //debug
|
||||
|
||||
_msg = buf;
|
||||
delete[] buf;
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ public:
|
|||
bool isValid()const;
|
||||
|
||||
static const int MAX_CONNECTIONS = 20;
|
||||
static const unsigned short DEFAULT_CONNECT_PORT = 3305;
|
||||
static const std::string DEFAULT_SERVER_IP;
|
||||
|
||||
private:
|
||||
int sock;
|
||||
|
|
|
@ -6,14 +6,32 @@
|
|||
*/
|
||||
|
||||
#include"../Server/Client.h"
|
||||
#include<string>
|
||||
#include<sstream>
|
||||
#include<iostream>
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
Client client;
|
||||
std::string ip = Socket::DEFAULT_SERVER_IP;
|
||||
unsigned short port = Socket::DEFAULT_CONNECT_PORT;
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << argv[1];
|
||||
ss >> port;
|
||||
}
|
||||
else if (argc >= 3)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << argv[1] << " " << argv[2];
|
||||
ss >> ip >> port;
|
||||
}
|
||||
|
||||
std::cout << "ip=" << ip << " port=" << port << std::endl; //debug
|
||||
Client client(ip, port);
|
||||
|
||||
client.run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,10 +6,21 @@
|
|||
*/
|
||||
|
||||
#include"../Server/Server.h"
|
||||
#include<sstream>
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
Server server;
|
||||
unsigned short port = Socket::DEFAULT_CONNECT_PORT;
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
std::stringstream ss(argv[1]);
|
||||
ss >> port;
|
||||
|
||||
std::cout << "port=" << port << std::endl; //debug
|
||||
}
|
||||
|
||||
Server server(port);
|
||||
|
||||
server.createConnection();
|
||||
server.listen();
|
||||
|
|
Loading…
Reference in New Issue