Skip to content

Commit 8ac2912

Browse files
committed
first working skeleton
0 parents  commit 8ac2912

File tree

5 files changed

+88
-0
lines changed

5 files changed

+88
-0
lines changed

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ssh-smtp
2+
3+
# C++ objects and libs
4+
5+
*.slo
6+
*.lo
7+
*.o
8+
*.a
9+
*.la
10+
*.lai
11+
*.so
12+
*.dll
13+
*.dylib
14+
15+
# Qt-es
16+
17+
*.pro.user
18+
*.pro.user.*
19+
moc_*.cpp
20+
qrc_*.cpp
21+
Makefile
22+
*-build-*

main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <QApplication>
2+
#include "server.h"
3+
4+
int main(int argc, char **argv) {
5+
QApplication app(argc, argv);
6+
Server server;
7+
return app.exec();
8+
}

server.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "server.h"
2+
#include <iostream>
3+
4+
using namespace std;
5+
6+
Server::Server(QObject* parent): QObject(parent)
7+
{
8+
connect(&server, SIGNAL(newConnection()),
9+
this, SLOT(acceptConnection()));
10+
11+
server.listen(QHostAddress::Any, 2525);
12+
}
13+
14+
Server::~Server()
15+
{
16+
server.close();
17+
}
18+
19+
void Server::acceptConnection()
20+
{
21+
client = server.nextPendingConnection();
22+
connect(client, SIGNAL(readyRead()),
23+
this, SLOT(startRead()));
24+
}
25+
26+
void Server::startRead()
27+
{
28+
char buffer[1024] = {0};
29+
client->read(buffer, client->bytesAvailable());
30+
cout << buffer << endl;
31+
client->close();
32+
}
33+

server.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <QtNetwork>
2+
#include <QObject>
3+
#include <QTcpServer>
4+
#include <QTcpSocket>
5+
6+
class Server: public QObject
7+
{
8+
Q_OBJECT
9+
public:
10+
Server(QObject * parent = 0);
11+
~Server();
12+
public slots:
13+
void acceptConnection();
14+
void startRead();
15+
private:
16+
QTcpServer server;
17+
QTcpSocket* client;
18+
};

ssh-smtp.pro

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
QT += core network
2+
3+
TARGET = ssh-smtp
4+
TEMPLATE = app
5+
6+
SOURCES += main.cpp server.cpp
7+
HEADERS += server.h

0 commit comments

Comments
 (0)