PDA

View Full Version : Qt as Client and Java as a Server. It's that possible ?



eroskoller
26th May 2009, 16:32
Hi to all and thats my first post …and I got a few doubts

I receive a project at school that consist on a little application “Client&Sever” so here a short description ..

Server Side: “Must be platform independent , able to switch over a few DBs without much of trouble and OO ”
sooo been a Java Web dev for 2 years my logical choice was “Java and Hibernate” that will do the job just fine fast and clean..

Cliente Side: “Light ,Fast and platform independent” and cannot be a “ webapp”:(

Here's my problem starts , I hate SWT/swing , it's not light not that fast and definally not pretty(my opinion) and on top off all this I actually never did a full GUI application.

Been a Linux/KDE user as well I know that Qt4 really rocks for GUI apps but a have no clue if it's possible to integrate those two technologies , How they will communicate and so on..
And I know about QT Jambi and because it's a dead end it's out , I can only use technologies well supported ..

If my post seems silly, I'm sorry I never did anything on QT/C++ before, but I will , in a near future.

Any suggestion I will appreciate

Tks :)

sry about my bad English..

nightghost
26th May 2009, 17:02
Its possbile. You can write the server in the language of your choice and the client in the language of your choice as long as the speak the same protocol.

For example we have a very simple Qt-App that waits on a updsocket and waits for plain textstrings. The "client" is a bashscript using netcat to send strings in the format. Very simple and works.

The command on the client side is:


netcat -u localhost 1234 "progressbar : 30"


And the server (in Qt) has something like this:



while (_udp_socket->hasPendingDatagrams()) {
QByteArray datagram;
datagram.resize(_udp_socket->pendingDatagramSize());

QHostAddress sender;
quint16 senderPort;

_udp_socket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort);

processTheDatagram(datagram);
}

void ProgressWindow::processTheDatagram(const QByteArray& datagram) {
QString data = QString(datagram).trimmed();

if(stringRepresentsAProgessUpdate(data)) {
//do something
}

}


An of couse in more complex scenarios you can also use a well known protocoll with cool features, but that depends on what you are doing.

But without C++ Experience this could be very difficult, because C++ is not so easy to handle and comfortable as Java (in my opinion)

eroskoller
26th May 2009, 17:26
thank you very much for the fast reply nightghost


i'll check this out it seems my way to go..

if u guys have any other references links (ideas) pls post i have to collect a lot information i still have to convict not only myself but my collegues (most are Delphi devs so even Java sounds uncomfortable for them)
:)

but i can say i'm already happy ..

nightghost
26th May 2009, 20:44
Perhaps http://doc.trolltech.com/4.5/examples.html will help you for network programming with Qt. There are a few Networkexamples if you scroll down.

wysota
26th May 2009, 21:25
What is the server supposed to do? Maybe you could implement it with Qt as well?

eroskoller
29th May 2009, 18:31
The server it's not supposed to do much ("persistence ,update retrieve User,Costumer info etc") the key thing is it must be cross-platform and i must be able to switch DBs (MySQL,Firebird and Postgres) .

wysota
29th May 2009, 19:19
The server it's not supposed to do much ("persistence ,update retrieve User,Costumer info etc") the key thing is it must be cross-platform and i must be able to switch DBs (MySQL,Firebird and Postgres) .

Which makes Qt an event better candidate for its implementation...