I want to create a Server for MJPEGs
and I found this tutorial: http://www.bogotobogo.com/Qt/Qt5_QTcpServer_Client_Server.php. But when I connect from a Web Browser like Chrome (Microsoft Telnet works fine), it shows connection reset.
After creating the server, I would like to show MJPEGs
on my browser (like an IP Camera does) using this: How to Create a HTTP MJPEG Streaming Server With QTcp-Server Sockets?
Here's my Server.cpp (A little modified) -
#include "stdafx.h"
#include "TCPServer.h"
TcpServer::TcpServer(QObject *parent) :
QObject(parent)
{
server = new QTcpServer(this);
connect(server, SIGNAL(newConnection()),
this, SLOT(newConnection()));
if (!server->listen(QHostAddress::Any, 9999))
qDebug() << "Server could not start";
else
qDebug() << "Server started!";
}
void TcpServer::newConnection()
{
QTcpSocket *socket = server->nextPendingConnection();
QByteArray header = "HTTP/1.1 200 OK\r\n";
socket->write(header);
QByteArray ContentType = "Content-Type: text/html\r\n";
socket->write(ContentType);
QByteArray Body = "Test";
socket->write(Body);
socket->flush();
socket->close();
}