Don't get this the wrong way, but are you coming from Java? I'm asking because this:QHostAddress().AnyIPv4
Doesn't make any sense in C++. What you probably want is to use the scope operator - :: to access one of the enum values. As for the error, please provide the full implementation of your TCP server and mention if you use threading, if so how. Also as mentioned by @koahnignew QTcpSocket(new QObject());
This leaks 2 objects one socket and one generic QObject. You need to provide a valid pointer from the object tree to make use of the automatic deletion Qt supplies for child objects.