simple daemon server with QT

1.1k Views Asked by At

Im trying to use Qt in order to create a server/client program that works with Inetd/xinetd on Linux OS.

I have added the service configuration file to /etc/xinetd.d/testServ with this text

service testServ
{
  socket_type = stream
  protocol = tcp
  wait = no
  user = root
 server = /usr/sbin/testServer
 }

Then i have added this line to the /etc/services

 testServ   5050/tcp    # the service uses the port nr 5050 and tcp protocol

I have created a special client program that connetcs to the server with the specefied port, which works without problems.

The problem is on the server program. I have written this code in the main function of the server program

Int main(int argc, char *argv[]) {
  qDebug()<<"starting the daemon version of server client app";
  QApplication app(argc, argv);
  setvbuf(stdout, NULL, _IONBF, 0);
  setvbuf(stdin,  NULL, _IONBF, 0);
  QFile fstdin;
  QFile fstdout;
  fstdout.open(stdout, QFile::WriteOnly|QFile::Unbuffered);
  fstdin.open(stdin, QFile::ReadOnly);
  CleintProcess clientproc (NULL, &slog, argc, argv, &fstdin, &fstdout);
  app.exec();
  return 0;
}

The problem on the server program is at the second line in the main function, the program does not continue after this line. If i print something after this line it does not appear on the screen, but if i print something before this line the print message appears. I dont know why Inetd/xinetd does not work with QApplication app(argc, argv);

when i delete this line and the other line (app.exe) the program terminated directly.

I need the QApplication, because i m using it manytimes in the object clientproc( ....).

Can you help me to solve this problem and get the qt working with inetd/xinetd on linux.

0

There are 0 best solutions below