File tree Expand file tree Collapse file tree 5 files changed +88
-0
lines changed
Expand file tree Collapse file tree 5 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 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- *
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+
Original file line number Diff line number Diff line change 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+ };
Original file line number Diff line number Diff line change 1+ QT += core network
2+
3+ TARGET = ssh-smtp
4+ TEMPLATE = app
5+
6+ SOURCES += main.cpp server.cpp
7+ HEADERS += server.h
You can’t perform that action at this time.
0 commit comments