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