Archived

This forum has been archived. Please start a new discussion on GitHub.

QT and Ice Basic Application Error

Hi,

Im trying to make basic (Hello world) TCP communication with ice on QT. I want to make a server which listens strings from client. Just that. I found some complex example (like chat demo but its very complex one and not for a beginner on ice). My problem is when i try to make communication, all program is closed with error.

Anyone has beginner example for qt? And send me please?
(My mail address : tolgatuna26@gmail.com)

---Here is my work---

My Printer.ice file:

module Demo {
interface Printer {
void printString(string s);
};
};



My Maincpp Code: (RED Part which trys to start server and give error)

#include "mainserver.h"
#include "ui_mainserver.h"
#include <Printer.h>
#include <printeri.h>
#include <Ice/Application.h>
#include <QDebug>


class Server : public Ice::Application
{
public:

virtual int run(int, char *[]);
};

int Server::run(int, char *[])
{
qDebug()<<"!!!Ice run is ok!!!";

Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("ASD");
qDebug()<<"Adapter declarataion";

Demo::PrinterPtr object = new PrinterI;
qDebug()<<"HelloPtr declarataion";

adapter->add(object, communicator()->stringToIdentity("ASD"));
qDebug()<<"ASD added to adapter";

adapter->activate();
qDebug()<<"Adapter activated";

communicator()->waitForShutdown();
qDebug()<<"Waiting for data";

return EXIT_SUCCESS;
qDebug()<<"Exit!";
}

MainServer::MainServer(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainServer)
{
ui->setupUi(this);

Server app;
char * argv[1];
argv[0]="argument";
//app.main(32,argv,"config.server");

}

MainServer::~MainServer()
{
delete ui;
}

void MainServer::changelineedit(std::string STR)
{
QString str = QString::fromUtf8(STR.data(),STR.size());
ui->lineEdit->setText(str);
}



My PrinterI.h Code:

#ifndef PRINTERI_H
#define PRINTERI_H

#include <Printer.h>
class PrinterI : public Demo::Printer
{
public :
virtual void printString(const std::string &, const Ice::Current &);
};


#endif // PRINTERI_H



My PrinterI.cpp code:

#include <IceUtil/IceUtil.h>
#include <Ice/Ice.h>
#include <printeri.h>
#include <mainserver.h>
#include <ui_mainserver.h>

using namespace std;

void PrinterI::printString(const string &gelenveri, const Ice::Current &)
{
MainServer *main;
main->changelineedit(gelenveri);
}



What is the problem of that code? And why the app.main(argc,argv) makes error. And what is the argc and argv in there?

In the example i saw some config files. Is there any way to run that code with a config file. Is there any way to make communication with udp?