Permalink
Browse files

first working skeleton

  • Loading branch information...
dnet committed Jul 15, 2013
0 parents commit 8ac29120a05891003b2a5c5a98d8b8c0e2a13562
Showing with 88 additions and 0 deletions.
  1. +22 −0 .gitignore
  2. +8 −0 main.cpp
  3. +33 −0 server.cpp
  4. +18 −0 server.h
  5. +7 −0 ssh-smtp.pro
@@ -0,0 +1,22 @@
ssh-smtp
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib
# Qt-es
*.pro.user
*.pro.user.*
moc_*.cpp
qrc_*.cpp
Makefile
*-build-*
@@ -0,0 +1,8 @@
#include <QApplication>
#include "server.h"
int main(int argc, char **argv) {
QApplication app(argc, argv);
Server server;
return app.exec();
}
@@ -0,0 +1,33 @@
#include "server.h"
#include <iostream>
using namespace std;
Server::Server(QObject* parent): QObject(parent)
{
connect(&server, SIGNAL(newConnection()),
this, SLOT(acceptConnection()));
server.listen(QHostAddress::Any, 2525);
}
Server::~Server()
{
server.close();
}
void Server::acceptConnection()
{
client = server.nextPendingConnection();
connect(client, SIGNAL(readyRead()),
this, SLOT(startRead()));
}
void Server::startRead()
{
char buffer[1024] = {0};
client->read(buffer, client->bytesAvailable());
cout << buffer << endl;
client->close();
}
@@ -0,0 +1,18 @@
#include <QtNetwork>
#include <QObject>
#include <QTcpServer>
#include <QTcpSocket>
class Server: public QObject
{
Q_OBJECT
public:
Server(QObject * parent = 0);
~Server();
public slots:
void acceptConnection();
void startRead();
private:
QTcpServer server;
QTcpSocket* client;
};
@@ -0,0 +1,7 @@
QT += core network
TARGET = ssh-smtp
TEMPLATE = app
SOURCES += main.cpp server.cpp
HEADERS += server.h

0 comments on commit 8ac2912

Please sign in to comment.