PDA

View Full Version : incommingConnection not called by QTcpServer



toufic.dbouk
5th January 2013, 14:14
Hi all,
i have this Server but whenever i try to connect to it from the client side
the incommingConnection is not being executed
can anyone help me to know the reason and how to fix it ?
Thanks in advance.

Server:

#include "server.h"
#include "ui_server.h"
#include <myclient.h>
#include <QtCore>
#include <QtGui>
#include <QTcpServer>
#include <QTcpSocket>

server::server(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::server)
{
ui->setupUi(this);

mServer=new QTcpServer(this);

QString rPath="whateverpath";
UserModel= new QFileSystemModel(this);
UserModel = new QFileSystemModel(this);
UserModel->setRootPath(rPath);
QModelIndex index= UserModel->index(rPath);
ui->UserListView->setModel(UserModel);
ui->UserListView->setRootIndex(index);

UserFileModel = new QFileSystemModel(this);
UserFileModel->setFilter(QDir::NoDotAndDotDot | QDir::Files | QDir::AllDirs);
ui->UserFilesTableView->setModel(UserFileModel);
ui->UserFilesTableView->resizeColumnsToContents();
ui->UserFilesTableView->setColumnWidth(3,266);
}

server::~server()
{
delete ui;
}

void server::on_StartPushButton_2_clicked()
{
// starting up the server on port number 1234

if(mServer->isListening())
{
QMessageBox::information(this,"Start Up","The Server is already running");
return;
}
if(mServer->listen(QHostAddress::Any,1234))
{

QMessageBox::information(this,"Start Up","The Server Has Started");
}
else
{

QMessageBox::information(this,"Start Up","The Server failed to Start up");
}

}

void server::on_shutdownPushButton_8_clicked()
{
//shutting down the server
if(!mServer->isListening())
{ QMessageBox::information(this,"Shutdown","The Server is Already Turned Off");
return;
}
mServer->close();
QMessageBox::information(this,"Shutdown","The Server is Turned Off");

}

void server::incomingConnection(int handle) //-----> this is never executed , i add a qDebug but it never shows
{
//when there is an incomming connection it is set to a client
myClient *mClient = new myClient(this);
mClient->SetSocket(handle);
}


Client:

#include "myclient.h"
#include "mytask.h"
#include <QtCore>

myClient::myClient(QObject *parent) :
QObject(parent)
{
}

void myClient::SetSocket(int Descriptor)
{
socket = new QTcpSocket(this);

connect(socket,SIGNAL(connected()),this,SLOT(conne cted()));
connect(socket,SIGNAL(disconnected()),this,SLOT(di sconnected()));
connect(socket,SIGNAL(readyRead()),this,SLOT(ready Read()));
socket->setSocketDescriptor(Descriptor);
qDebug() << "client connected";

}

void myClient::connected()
{
qDebug() << "client connected event";
}

void myClient::disconnected()
{
qDebug() << "client disconnected";
}

void myClient::readyRead()
{
//do something
}

Santosh Reddy
5th January 2013, 14:36
Server is listening, but where is it accepting new connection?

You should have something like this


connect(mServer, SIGNAL(newConnection()), ....);
or
if(mServer->hasPendingConnections())
{
QTcpSocket * clientSocket = mServer->nextPendingConnection ();
clientSocket->readAll();
...
}

toufic.dbouk
5th January 2013, 15:46
thanks for your reply
but isnt the incommingConnection function should accept the incomming connections and queue them ?

Added after 21 minutes:

i added a newConnection() public slot to the server class
implemented it as such

void Server::newConnection()
{
qDebug() << "new connection ";
if(mServer->hasPendingConnections())
{
QTcpSocket *socket = mServer->nextPendingConnection();
qDebug() << "connected"l
}

}


then in my constructor :
i added

connect(mServer,SIGNAL(newConnection()),this,SLOT( newConnection());

but again non of the qDebugs were executed...
i rly need some help here
Best regards.

boudie
5th January 2013, 18:06
I think you better have a look here:
http://qt-project.org/doc/qt-4.8/examples-network.html

toufic.dbouk
5th January 2013, 21:45
well i fixed the problem
but now on the server side
when the file is being uploaded by the client to the server
the whole GUI just freezes
i know its from the

while(Socket.waitForReadyRead())
{
//read from socket
// append to QByteArray
}

so does anyone have a solution to this ?
any other way to not freeze the GUI ?
i was actually thinking of send the file size before the data
read it separately then doing the while loop as such :
loop until the block size is equal to the file size sent
if anyone have tried this , may you hint me how to send the file size alone before the data ?
thanks is advance.

toufic.dbouk
6th January 2013, 16:23
Non of you guys or admins want to reply?
i need some help here.
thanks

wysota
6th January 2013, 17:08
I can only suggest to use signals and slots instead of waitFor* calls.

toufic.dbouk
6th January 2013, 20:15
well in other words how can i transfer that waitForreadyRead() loop into signals and slots ?
im not able to get the point of what you are saying
a sample code or pseudo code would be helpfull if not at least some logic...
thanks.

elmasmalo1
6th January 2013, 20:22
well i fixed the problem
but now on the server side
when the file is being uploaded by the client to the server
the whole GUI just freezes...

Hi there!

The solution to your problem will be adding a thread to your fuction thus when you receive data, it just simply goes in background doing its job while in the meanwhile you can still use other portions of your program. I think this is so far the best solution available to you =D

You can find more about QThread HERE (http://qt-project.org/doc/qt-5.0/qtcore/qthread.html) With latest Qt-5.0.0 Support =D Head over "Detailed Description" so you can see whats happening in there

toufic.dbouk
6th January 2013, 21:33
threads... thanks ill give it a try
but i have a question
at the server side i create a QTcpSocket for ever client that connects in a class
now how can i move this exact same socket to the thread so that i does the job right ?
like if i created a new tcpsocket at the thread class it would be in an unconnected state ?
thanks for your fast respons.

wysota
6th January 2013, 22:07
well in other words how can i transfer that waitForreadyRead() loop into signals and slots ?
Yes. handle readyRead() and all will be fine.


a sample code or pseudo code would be helpfull if not at least some logic...
Sample code is in Qt docs.


threads... thanks ill give it a try
No, please don't give threads a try. That's a wrong approach here.

elmasmalo1
6th January 2013, 22:16
For moving that specific socket into the thread will be to make your QTcpSocket in your QThread Class and make it to listen for incoming connections and then serialize that Socket in order to identify it and there you have it. That QThread Class will be the one in charge of Receiving Incomming Connections and handling them over the program as you desire.

I should call a practical Trial & Error sample where you make few threads and each of them you assign your Incomming Connections function... and test with different settings...

If you need more reference I can suggest this series of video tutorials that could come handy in your project:

C++ Qt 28 - QThread Part #1: Creating a Thread (http://www.youtube.com/watch?v=JaGqGhRW5Ks)
C++ Qt 29 - QThread Part #2: The Priority (http://www.youtube.com/watch?v=fM2THwKYqq8)
C++ Qt 30 - QThread Part #3: The QMutex Class (This is what you will be needing in order to Serialize Objects in this case your Socket) (http://www.youtube.com/watch?v=5WEiQ3VJfxc)
C++ Qt 31 - QThread Part 4: Threads and GUI (This will teach you how to organize threads and use them normally in a GUI Form) (http://www.youtube.com/watch?v=PR6wVy7Et1A)
C++ Qt 33 - QThread Part 5: The Waiting Thread Member (http://www.youtube.com/watch?v=LCIes6xehlA)
C++ Qt 35 - QThread Part 6: Threading done correctly in Qt (http://www.youtube.com/watch?v=yazMHbIew0Q)

I suggest you to get a good grip over the concepts of Threading in Qt with these tutorials and later on deploying the techniques learned here into your project, only then you will have a vast knowledge on how to over control your program =D

Hope I helped in something.

toufic.dbouk
6th January 2013, 22:18
well i can figure out what u mean by handle the readyRead
i was just reading the Qthreads documentation and trying to solve my problem
basicly if a thread handles the readyRead() singnal then my problem would be solved
because then the thread will wait for the data to be written and block while my main thread which is my GUI
would be working fine
right ?
im confused now
im u just give me more hints on your approach ill be greatfull
Thanks.

wysota
6th January 2013, 23:42
basicly if a thread handles the readyRead() singnal then my problem would be solved
You don't need an extra thread to handle readyRead(). The main thread will do that just fine. Just connect the socket's readyRead() signal to a slot and read data from the socket from within that slot. Then when you receive the signal again, read data from the socket again, etc.

Using threads for reading socket data is just stupid. Sure you can do it, you can even start 20 threads for each client if your operating system lets you but what's the point?

anda_skoa
7th January 2013, 14:39
but isnt the incommingConnection function should accept the incomming connections and queue them ?


QTcpServer::incomingConnection will be called for each accepted connection.
The problem in your original code is that you are expecting server::incomingConnection to be called, but server is a subclass of QMainWindow.

Cheers,
_

toufic.dbouk
7th January 2013, 15:19
QTcpServer::incomingConnection will be called for each accepted connection.
The problem in your original code is that you are expecting server::incomingConnection to be called, but server is a subclass of QMainWindow.

Cheers,
_

and thats exactly what i want , i want the QTcpServer::incommingConnection to be called when a connection is established after which ill handle it the way i want.
well server in my class is an instance of QTcpServer class , hence i guess , for sure it will signal the QTcpServer::incommingConnection when a connection is accepted even if i subclassed from QMainWindow, i still have that QTcpServer object with its incommingConnection
so i still cant see the problem , why isnt it being invoked ?
if im wrong , correct my information.
thanks.

Added after 20 minutes:


You don't need an extra thread to handle readyRead(). The main thread will do that just fine. Just connect the socket's readyRead() signal to a slot and read data from the socket from within that slot. Then when you receive the signal again, read data from the socket again, etc.
Using threads for reading socket data is just stupid. Sure you can do it, you can even start 20 threads for each client if your operating system lets you but what's the point?

well the whole point of using threads in my case is that i want a thread other than the main thread of my application to handle the readyRead singal so that when data is being written to the server , the servers GUI wont block or freeze. Thats all my need from a thread.
i already linked the readyRead signal to a slot to take care of the reading and writing data to the sever but still it is managed by the main thread resulting in blocking my GUI
because i used waitforReadyRead as a loop to write the whole data to server.
if threads is a stupid thing to do in my case, im sorry for doing it because i dont actually know how to make it non block method , even though i tried several times.
i have already posted my code at the first post , so if u could fix it to a non blocking way by a sample code , id be waaaay too greatfull.
thanks for your understanding and best regards.

wysota
7th January 2013, 15:42
well the whole point of using threads in my case is that i want a thread other than the main thread of my application to handle the readyRead singal so that when data is being written to the server , the servers GUI wont block or freeze. Thats all my need from a thread.
And how much data is it? 100GB/s? 1GB/s? 1MB/s? 10kB/s? Do you also create a new thread if you want to write 10kB to a file? You don't because it takes mili if not microseconds to do it so your GUI will not even notice that. It's exactly the same with sockets -- your application only stores data in a system buffer for the socket and returns immediately. The rest is taken care of by the OS and hardware outside the scope of your application. Thus there is no need to create threads when reading or writing data from/to a socket. Without threads you end up with much cleaner, safer and quicker code.


i already linked the readyRead signal to a slot to take care of the reading and writing data to the sever but still it is managed by the main thread resulting in blocking my GUI
because i used waitforReadyRead as a loop to write the whole data to server.
If you use waitForReadyRead() then there is no point in connecting to the readyRead() signal. You only need to do the latter -- connect to readyRead() and read the available data in the socket when the slot is called.


if threads is a stupid thing to do in my case, im sorry for doing it because i dont actually know how to make it non block method , even though i tried several times.
No, you haven't, because all the time you end up calling waitForReadyRead() despite being told not to do it.


i have already posted my code at the first post , so if u could fix it to a non blocking way by a sample code , id be waaaay too greatfull.

void myClient::readyRead() {
QByteArray ba = socket->readAll();
doSomethingWithData(ba);
}

toufic.dbouk
7th January 2013, 16:52
now thats a well and good explained reply.
thank you for your patience.
but trust me i did try and more than once to not use the waitforReadyRead loop
and when i dont, the file sent just is not fully received
thats why i was insisting on using it just to solve my problem ( it caused another problem , blocking the GUI , so i was trying to solve my other problem)
my GUI freezes at a 7 MB file , even a 2 MB file lead to a half a sec or so of freezing , thats why it is really annoying and cant overlook it. a 1GB file would block it forever until it is fully saved on the server.
anyway i will try to not use the waitforRedayRead() again and see how it goes another time, maybe i had a silly hidden mistake or something.
again Iam really thankful for your concern.

wysota
7th January 2013, 16:57
and when i dont, the file sent just is not fully received
How many times was readyRead() called for your file? What did you do with the data after receiving it? Show your code please. And while you're at it, fix the thing anda_skoa mentioned.

toufic.dbouk
7th January 2013, 17:12
void myClient::readyRead()
{
QString fPath("C:\\Users\\Ali\\Desktop\\music");
QByteArray block;

block=socket->readAll();
socket->flush();
qDebug()<< "block: " << block;
socket->waitForReadyRead();

QString fName= QString(block);
QFile sentFile(fPath +QDir::separator() + fName);
block.clear();

if(!sentFile.exists())
{
sentFile.open(QFile::WriteOnly);
while(socket->waitForReadyRead())
{
QByteArray block= socket->readAll();
qDebug()<< "read: " << block.size();
sentFile.write(block);
block.clear();
}
sentFile.close();
}
}


thats how iam saving the data.
this readyRead slot is connected to the sockets readyRead Signal

now when this loop is removed while(socket->waitForReadyRead())
the file wont be fully saved, it will be corrupted. If its a picture , the first couple of pixels will be saved.

i replied to anda_skoa but he havnt replied back , i need him to reply to my question first to understand whats going on.
for now i connected the newConnection to another slot that will handle the work.

wysota
7th January 2013, 17:47
void myClient::readyRead()
{
QString fPath("C:\\Users\\Ali\\Desktop\\music");
QByteArray block;

block=socket->readAll();
socket->flush();
qDebug()<< "block: " << block;
socket->waitForReadyRead();

QString fName= QString(block);
QFile sentFile(fPath +QDir::separator() + fName);
block.clear();

if(!sentFile.exists())
{
sentFile.open(QFile::WriteOnly);
while(socket->waitForReadyRead())
{
QByteArray block= socket->readAll();
qDebug()<< "read: " << block.size();
sentFile.write(block);
block.clear();
}
sentFile.close();
}
}


thats how iam saving the data.
this readyRead slot is connected to the sockets readyRead Signal
You didn't get my question. I asked you specifically -- how many times is readyRead() called for your file? Remove all content of the method and only put a debug statement that prints something and a call to socket->readAll(). Then run the program and see how many times the method is called for your file. Then sit down and think why it happens and how to change your code.


i replied to anda_skoa but he havnt replied back , i need him to reply to my question first to understand whats going on.
for now i connected the newConnection to another slot that will handle the work.
I can tell you what is going on. There is a class A that has a virtual method x() and class B that doesn't have that method and you are implementing B::x() hoping that whatever was calling A::x() will call B::x() now. This is not the case in C++. You need to subclass A and reimplement x() for it to be called.

toufic.dbouk
8th January 2013, 11:37
You didn't get my question. I asked you specifically -- how many times is readyRead() called for your file? Remove all content of the method and only put a debug statement that prints something and a call to socket->readAll(). Then run the program and see how many times the method is called for your file. Then sit down and think why it happens and how to change your code.


hello Wysota,
sorry for the late reply i got busy last day
anyway i tried what u told me , the readyRead is emiited lots of time depending on the file size for sure
i was able to get rid of that waitforReadyReady loop
data is fully written on server
BUT STILL THE WHOLE GUI FREEZES!!
it freezes as long as the file is being written
so actually this didnt solve my problem...
heres the code:

void myClient::readyRead()
{
QString fPath("path");
QByteArray block;
QString fName= "test1";
QFile sentFile(fPath +QDir::separator() + fName);
sentFile.open(QFile::WriteOnly | QFile::Append);
block=socket->readAll();
socket->flush();
qDebug()<< "block: " << block.size();
sentFile.write(block);
}

so do i use threads for this to not freeze ? or dd i do a mistake or missed something ?
please let me know ASAP
your help is really appreciated
thanks.

wysota
8th January 2013, 11:47
1. open the file once instead of reopening every time the method is called.
2. don't flush the socket.
3. create a QTime object at the beginning of the method, call its start() method and prints the result of its elapsed() method at the end of the readyRead() function. See how much time (in miliseconds) it takes to execute the method. It shouldn't take more than 100ms unless you are using a really low-end machine or you have problems elsewhere in your design which causes unnecessary lags and buildup in pending socket data.
4. also see how large blocks of data you receive, if you operate on the boundary of available memory, you might be getting into slowdowns caused by swapping, try to eliminate those (e.g. by not reading all data at once but instead reading it in smaller blocks that are guaranteed to fit in ram).

See if it helps.

toufic.dbouk
8th January 2013, 12:40
1. open the file once instead of reopening every time the method is called.
2. don't flush the socket.

do you mean that i should open the file outside the readyRead slot ?
may i ask why flushing the socket would result in such a slow or freeze of GUI ?

ill try all of what you said and let you know the result

anda_skoa
8th January 2013, 12:42
and thats exactly what i want , i want the QTcpServer::incommingConnection to be called when a connection is established after which ill handle it the way i want.


As I said you need to create a subclass of QTcpServer for that and then reimplement/override the virtual method incomingConnection()



well server in my class is an instance of QTcpServer class


The class "server" is a QMainWindow, not a QTcpServer



for sure it will signal the QTcpServer::incommingConnection when a connection is accepted even if i subclassed from QMainWindow, i still have that QTcpServer object with its incommingConnection


Yes, QTcpServer works totally independent of where you put it, whether a main window or somewhere else.



so i still cant see the problem , why isnt it being invoked ?


QTcpServer::incomingConnection() is invoked.

If you want your method to be invoked instead, you have to derive from QTcpServer and reimplement/override it.

Your original code looks like you were assuming that the method of a totally different object (server::incomingConnection) would somehow magically be invoked.
C++ might look like magic from time to time but I am afraid it is not :)

Cheers,
_

toufic.dbouk
8th January 2013, 12:53
The class "server" is a QMainWindow, not a QTcpServer
what i meant here is that i have a QTcpServer instance(mServer) in my server class
so i was expecting the incommingConnection to be invoked from it



Your original code looks like you were assuming that the method of a totally different object (server::incomingConnection) would somehow magically be invoked.
C++ might look like magic from time to time but I am afraid it is not :)
its nice to have some sense of comedy from time to time, it removes the feeling of student-instructor at such forms:P
thanks ill give what u said a try and reply back later.

wysota
8th January 2013, 14:27
do you mean that i should open the file outside the readyRead slot ?
Yes, that's correct. Opening and closing the file takes some time, why waste it?

may i ask why flushing the socket would result in such a slow or freeze of GUI ?
I didn't say it does (maybe it does, maybe not). What flush does is that it forces all data pending to be written to be forced into the socket (AFAIR it sets the P(U)SH flag in TCP). Since you're not writing anything to the socket there is no point in flushing it, it's a pure waste of time. Even if you were writing something to the socket, flushing it in the part of code related to reading from the socket wouldn't make much sense too.

toufic.dbouk
8th January 2013, 14:43
I didn't say it does (maybe it does, maybe not). What flush does is that it forces all data pending to be written to be forced into the socket (AFAIR it sets the P(U)SH flag in TCP). Since you're not writing anything to the socket there is no point in flushing it, it's a pure waste of time. Even if you were writing something to the socket, flushing it in the part of code related to reading from the socket wouldn't make much sense too.
sure this makes sense thanks.
but how can i open the file before the readyRead slot is invoked even if the file isnt there ?
in other other words , im getting the name of the file from the readyRead slot and creating that file too when the readyRead Slot is executed ?
so how can i open the file before executing the readyRead slot ?

wysota
8th January 2013, 15:03
sure this makes sense thanks.
but how can i open the file before the readyRead slot is invoked even if the file isnt there ?
in other other words , im getting the name of the file from the readyRead slot and creating that file too when the readyRead Slot is executed ?
so how can i open the file before executing the readyRead slot ?

Open it when you receive the file name from the socket and then keep it open (you can create QFile on the heap or make it a member variable of your class). Note that you may receive the file name in parts, you have to take that into account when implementing the slot that handles incoming data.

toufic.dbouk
8th January 2013, 15:54
alright things are getting better i guess
but i need you to tell me something
if i have a block of code in a method (Readyread Slot ) which is entered everytime the readyRead Signal is emitted
in this method i want part of the code to not be executed but for the first time it enters
is there any easy way to lock such part of code so that it is not executed on the 2nd , third , fourth etc executions of the method?
i havnt slept for a while so honestly i dont know how to do it
may you help in this please?

wysota
8th January 2013, 20:37
if i have a block of code in a method (Readyread Slot ) which is entered everytime the readyRead Signal is emitted
in this method i want part of the code to not be executed but for the first time it enters
is there any easy way to lock such part of code so that it is not executed on the 2nd , third , fourth etc executions of the method?
i havnt slept for a while so honestly i dont know how to do it
may you help in this please?

Have a bool member variable, initialize it to something and then check its value in the method and flip it to the other value. Or simply have a QFile member variable and each time you enter the method, check if the file is open or not.

toufic.dbouk
8th January 2013, 20:57
i guess i cant do that cuz :

void myFucntion()
{

bool lock=false;

while(lock==false)
{
/* code that i want to block after first execution*/

bool = true;

}

// rest of the code




}

this will result in re-initialization off variable bool to false everytime the method is executed which will result in the
execution of my code

if u suggest to define in it header tell me how cuz i tried several times and each resulted in a different error.
thanks

wysota
8th January 2013, 21:02
I said a (class) member variable, not a local variable.


class myClient : ... {
...
myClient(...) : ... {
...
isInitialized = false;
}
private:
bool isInitialized;
};

void myClient::readyRead() {
if(!isInitialized) {
isInitialized = true;
// executed once
}
// executed every time
}

toufic.dbouk
8th January 2013, 21:06
error: ISO C++ forbids initialization of member 'lock'
error: making 'lock' static
error: ISO C++ forbids in-class initialization of non-const static member 'lock'

these are the errors when i declare lock in my header as : bool lock=false;

if i make it static and const i wont be able to change it

if i make it just static : error: ISO C++ forbids in-class initialization of non-const static member 'lock'

thats what i meant by i tried several times each with an error

wysota
8th January 2013, 21:16
Look at the code I posted and compare it with yours.

toufic.dbouk
8th January 2013, 21:33
Look at the code I posted and compare it with yours.

yea sry i wrote the reply before the code appear

it is working , the readyRead SLot is almost good
its not blocking that much i guess the slight freeze might be from my laptop even though its a corei7 toshiba with 8GB of rams
but i havnt turned it off for a quite long time :P

ok so lets continue
do u have any easy idea to do authentication ?
what i mean is that when my client connects he will have to enter a user name and pass and email
i want the server to do authentication on this after he signs up
so the next time he logs in the server can authenticate
if the user name and pass are correct he will have access else he wont
can it be done without saving the data to a file on the server ?
should i encrypt the password ?

wysota
8th January 2013, 21:36
This is really out of scope of this forum. Although I have some knowledge regarding the topics you are asking about, I suggest you read some articles on designing protocols and services. I can only suggest that you follow standards instead of reinventing the wheel. E.g. think about using HTTP as your application protocol, maybe it suits your needs.

toufic.dbouk
8th January 2013, 21:40
ahhh...

may you give me your email so that you help me on this cuz its out of scop of this form? if your are willing to help me for sure

i thought you would know how to use the QAuthenticator and whether it can suit my need or not
i couldnt fine much tutorials about it but for the qt documentations

one more thing
i forgot to ask when should i close the file ?
i cant close it at that same readyRead slot , cuz then i would have done nothin
so whats the solution ?
i really appreciate your help.
thanks.

wysota
8th January 2013, 21:47
I will not design a protocol for you. The problem is not about Qt, it is about your understanding of how networking works. I cannot teach you that via email. This is not a task for 10 minutes, you have to do some reading and thinking. Choosing the right classes for the job is the last step that you need to do. First you need to go through a bunch of others.

toufic.dbouk
8th January 2013, 21:52
i ddnt ask to design a protocol for me
i simply asked for help via email thats all
i know networking, i took networking courses and do understand what you say about tcp and http and all that networking stuff
dont go to NAT cuz i havnt took that yet :P
im obliged to use what im using here and i have to use a authentication way and encrypting password
anyway if thats out of scope its fine.
but u ddnt answer me about the QAuthenticator ?

wysota
8th January 2013, 23:41
i ddnt ask to design a protocol for me
i simply asked for help via email thats all
i know networking, i took networking courses and do understand what you say about tcp and http and all that networking stuff
Great. In that case you'll know how to coupe with things like segment fragmentation (although history of this thread claims to think otherwise). That's the basic thing you need to be aware of. There is a difference between "networking" and "protocol design", I hope you understand it.


but u ddnt answer me about the QAuthenticator ?
QAuthenticator is a class for carrying realm/user/password information, usually for HTTP-Basic authentication. It doesn't do any authentication on its own, it's just means of storing information.

toufic.dbouk
9th January 2013, 09:48
Alright thank you wysota.
ill let you know if i need any further help.
Best Regards and thanks for your helpful replies.

anda_skoa
9th January 2013, 13:37
what i meant here is that i have a QTcpServer instance(mServer) in my server class
so i was expecting the incommingConnection to be invoked from it

QTcpServer::incomingConnection on mServer is invoked as expected. You can easily verify that by putting a debugger break point into it.

Actually the base class implementation adds a QTcpSocket to pending connections and emits newConnection(), so you don't even have to use a break point for verification :)

Cheers,
_