00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <qsocket.h>
00012
00013 #include <stdlib.h>
00014 #include <mythtv/mythcontext.h>
00015
00016 #include "serversocket.h"
00017
00018
00019 MTDServerSocket::MTDServerSocket(int port, QObject *parent)
00020 :QServerSocket(port, 1, parent)
00021 {
00022 if(!ok())
00023 {
00024 VERBOSE(VB_IMPORTANT,
00025 QString("MTDServerSocket Something is wrong trying to start "
00026 "with port=%1\nYou've probably got another copy of mtd "
00027 "already running.\nYou might want to try "
00028 "\"ps ax | grep mtd\".\nThis copy will now exit ...")
00029 .arg(port));
00030 exit(0);
00031 }
00032 }
00033
00034
00035 void MTDServerSocket::newConnection(int socket)
00036 {
00037 QSocket *new_socket = new QSocket(this);
00038 connect(new_socket, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()));
00039 connect(new_socket, SIGNAL(connectionClosed()), this, SLOT(discardClient()));
00040 new_socket->setSocket(socket);
00041
00042 emit(newConnect(new_socket));
00043 }
00044
00045 void MTDServerSocket::discardClient()
00046 {
00047 QSocket *socket = (QSocket *)sender();
00048 if(socket)
00049 {
00050 emit(endConnect(socket));
00051 }
00052 }
00053