Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. qtcpsocket
    Log in to post

    • SOLVED QTcpServer/Socket remain connected while client dies
      General and Desktop • qtcpsocket qtcpserver • • Dariusz  

      2
      0
      Votes
      2
      Posts
      22
      Views

      Solved. For some reason one of my QThread workers send a message on socket and did not post it to Socket thread... that caused it to internally "crash" without telling any1 about it and thus became "broken" internally. Once I posted it to correct thread everything started to work again... sigh! :- )
    • UNSOLVED Sending data over internet
      General and Desktop • qtcpsocket qtcpserver help internet • • BodyaGunko  

      2
      0
      Votes
      2
      Posts
      45
      Views

      @BodyaGunko Hi and welcome. That's what running a web/HTTP server and exposing the IP over the Internet allows, from any client with a web browser.
    • UNSOLVED JSON file transfer from Rpi to PC
      Mobile and Embedded • qtcpsocket raspberry pi3 qt for windows qjson • • Andrex_Qt  

      5
      0
      Votes
      5
      Posts
      125
      Views

      @JonB sorry for late reply. you suggestion worked well. i followed https://wiki.qt.io/WIP-How_to_create_a_simple_chat_application and modified my code according to that. now at sender side looks like this QJsonDocument doc1; QFile j("/home/first.JSON"); if(j.exists()) { if(j.open(QIODevice:: ReadOnly| QIODevice::Text)) { jstr=j.readAll(); doc1= QJsonDocument::fromJson(jstr.toUtf8()); } j.close(); QDataStream clientStream(socket); clientStream.setVersion(QDataStream::Qt_5_7); // Create the JSON we want to send QJsonObject message; message[QStringLiteral("type")] = QStringLiteral("message"); clientStream << QJsonDocument(doc1).toJson(); } } else { ui->l_err->show(); ui->l_err->setText("Connection refused. Please check server."); } and used server application from the link above at receiver end. this works well. I have tested this with JSON file having 3000 object. Will this work for 50,000 samples and more possibly 1500000 objects?
    • UNSOLVED QTcpSocket : readRead() not being triggered when data is written on the socket
      General and Desktop • qtcpsocket qtcpserver tcp tcpsocket tcp server • • RBLL  

      11
      0
      Votes
      11
      Posts
      295
      Views

      The edited part of @JonB is important, you have to read the data.
    • SOLVED do multiple calls to write of QTcpSocket/QWebSocket overwrite previous bytes which are not yet written?
      General and Desktop • qtcpsocket tcp networking qwebsocket • • noone  

      11
      0
      Votes
      11
      Posts
      232
      Views

      after removing the lines:- auto img = QImage::fromData(rawimg); QLabel *myLabel = new QLabel; myLabel->setPixmap(QPixmap::fromImage(img)); myLabel->show(); it works perfectly with more than 20*3 images
    • UNSOLVED Incomplete data in QDataStream when reading from QTcpSocket
      General and Desktop • qtcpsocket qtcpserver qbytearray qdatastream • • RBLL  

      16
      0
      Votes
      16
      Posts
      256
      Views

      Maybe that QByteArray is the culprit, you could try rewrite into more vanilla standard: ... { QByteArray block; QBuffer buffer(&block); buffer.open(QIODevice::WriteOnly); QDataStream out(&buffer); ... at least you would expose more stuff to the debugger :-)
    • SOLVED read single byte from socket ethernet
      Mobile and Embedded • qtcpsocket server client ethernet in qt read one byte • • vishbynature  

      7
      0
      Votes
      7
      Posts
      288
      Views

      @aha_1980 ok, thanks help again. regards.
    • UNSOLVED QSocket - change from old QT.... whats new ?
      General and Desktop • qtcpsocket • • Dariusz  

      3
      0
      Votes
      3
      Posts
      143
      Views

      Hi, You have a porting guide here in Qt's documentation.
    • UNSOLVED QSslSocket and QTcpSocket ... how to know if the connection is incorrect
      General and Desktop • qtcpsocket qsslsocket • • healermagnus  

      3
      0
      Votes
      3
      Posts
      301
      Views

      @healermagnus said in QSslSocket and QTcpSocket ... how to know if the connection is incorrect: Any ideas what I'm missing? You want a delayed handshake. Ideologically it goes like this: You create the QSslSocket object, but operate it as a QTcpSocket. The server and client exchange TCP messages (as per your liking) to try and negotiate whether they should stay in plain TCP or in SSL mode. When the connection is decided to be used over SSL the client calls startClientEncryption, while the server socket calls startServerEncryption to begin the actual SSL handshake. Connecting the TCP error and sslErrors() signals is a must.
    • SOLVED Ethernet communication between RPi and local PC
      Mobile and Embedded • qtcpsocket raspberry pi3 qt 5.9.0 ethernet in qt • • vishbynature  

      12
      1
      Votes
      12
      Posts
      519
      Views

      @aha_1980 ok, i understood what you said.
    • UNSOLVED Send and receive strings with QTcpSocket
      General and Desktop • qtcpsocket tcp server client • • Captain Matsuyo  

      6
      0
      Votes
      6
      Posts
      944
      Views

      QTcpSocket socMeteo; QTextStream texte(&socHauteur); These are 2 different sockets. What are you trying to do? It should be something like: auto socMeteo = new QTcpSocket(this); socMeteo->connectToHost("192.168.1.35",10001); connect(socMeteo,&QTcpSocket::connected,socMeteo,[socMeteo]()->void{ QTextStream texte(socMeteo); texte<<"Bonsoir\n"; });
    • UNSOLVED QServer slow down the reading of the serial port
      General and Desktop • qthread qtcpsocket qtcpserver • • Dooham  

      9
      0
      Votes
      9
      Posts
      460
      Views

      I dont know why, but if I set the conexion between server and client first and then I call the function startSerialPort(), the reading speed is the normal. But this method just works with the first conexion. The second conexion already experiment the decrease of the reading speed. void MyServer::startSerialPort() { mipuerto2 = new MySerialPort; msgRec = new MensajeRecibido; msgSent = new MensajeEnviar; connect(mipuerto2, SIGNAL(msgChanged(QByteArray*)), this, SLOT(getMens(QByteArray*))); connect(mipuerto2, SIGNAL(msgChanged(QByteArray*)), this, SLOT(idMensaje(QByteArray*))); connect(msgSent, SIGNAL(tienesMensaje(QString*)), this, SLOT(setRecibido(QString *))); mipuerto2->openSerialPort(); } qDebug()<<socketDescriptor<<"Connecting... "; socket = new MySocket(socketDescriptor); controlador++; QThread *thread = new QThread; qDebug()<<thread->currentThreadId(); connect(this, SIGNAL(mensChanged(QByteArray*)), socket, SLOT(getMsg(QByteArray*))); connect(socket, SIGNAL(mensajeEnviarSocket(QByteArray*)), this, SLOT(sendMens(QByteArray*))); connect(socket, SIGNAL(disconnected()),thread, SLOT(quit()) ); connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater())); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); connect(thread, SIGNAL(started()), socket, SLOT(funcionamiento())); connect(socket, SIGNAL(disconnected), this, SLOT(desconectar())); socket->moveToThread(thread); thread->start(); if(controlador==1){ startSerialPort(); }else if (controlador>1) { mipuerto2->closeSerialPort(); delete mipuerto2; startSerialPort(); }
    • SOLVED QTcpSocket doesn't emit the signal ReadyRead()
      General and Desktop • qthread qtcpsocket qtcpserver • • Dooham  

      3
      0
      Votes
      3
      Posts
      1253
      Views

      @koahnig You were right, changing the pointer this to socket in the connection function of readyRead, it worked. Thanks you
    • SOLVED A connect function slow down the connection between QTCPserver and client
      General and Desktop • qtcpsocket qtcpserver • • Dooham  

      4
      0
      Votes
      4
      Posts
      427
      Views

      @jsulm Hi, thanks for your answer and sorry for my delay, I haven't login in the forum during the weekend. You are right, I eliminated this line and I didn't get this trouble.
    • SOLVED How to send the lecture of a Serial Port through a QTcpServer to a Client
      General and Desktop • qserialport qtcpsocket qtcpserver • • Dooham  

      5
      0
      Votes
      5
      Posts
      476
      Views

      @fcarney You were right. I changed the line where I initialize the serialport to a position before the connect and that works. Thanks!
    • UNSOLVED QTCPSocket with Qt 5.11.1 and Qt 5.6.1
      General and Desktop • qtcpsocket socket network socket connect failure connect problem • • silau  

      4
      0
      Votes
      4
      Posts
      870
      Views

      @silau It looks good but ldd doesn't always report exactly what is actually happening when you run your exe. It's a good start though. If you really wanted to trace it further you would have to ldd on each of those libs to see what they link. One of them could be using the 5.6 or whatever other version you may have. That being said I find that to be a bit unlikely though. When I get a little bit of time later today I will run your code using Arch linux and 5.11 and see what happens. That will help determine if maybe it's a bug in Qt (which I highly doubt for something that big). If it works for me the next steps for you would be to run it in the debugger and step through the working 5.6 one during socket connections and then the broken 5.11 one and see what is different. Another option is take it down to the simplest form and just use the chat example or something from Qt and see if it works with 5.11 and then try to see what is different. I'll let you know what I find out on my linux/Qt 5.11 in a bit. Edit: Didn't get a chance today, was really busy. I will run a quick test tomorrow some time though.
    • SOLVED Need Help with getting a slot executed in the correct thread
      General and Desktop • network qtcpsocket qtcpserver server - client qthreadpool • • Curtwagner1984  

      8
      0
      Votes
      8
      Posts
      1716
      Views

      @VRonin said in Need Help with getting a slot executed in the correct thread: the default implementation of QThread::run starts an event loop so if you use the method described in that link everything will work out of the box Indeed it does! Thanks!
    • UNSOLVED run fortune Client Example on Amazon AWS Server
      General and Desktop • qtcpsocket qtcpserver server server - client • • Allerknappe  

      3
      0
      Votes
      3
      Posts
      661
      Views

      @Allerknappe should your question better suited for AWS support team? or cloud forum? It seems not related to Qt itself. Anyway, from little experience with a (non Qt) REST server running in AWS, in that case the server was configured with "internal" IP and then the AWS security team forwarded the proper port(s) so the solution could be available from outside.
    • SOLVED Problem with QTcpSocket
      General and Desktop • qtcpsocket bidirectional • • JCBaraza  

      3
      0
      Votes
      3
      Posts
      1652
      Views

      @aha_1980 said in Problem with QTcpSocket: Hi @JCBaraza, I hope you are well aware that the waitForReady... functions can only be used in threads. If you don't have a thread (beside the main thread), you must use signals&slots, like the Fortune Client example. Hi aha1980, Thanks a lot for your quick answer. No, I'm affraid I didn't know about that. When I saw the Qt examples with sockets, I rapidly discarded using signals and slots because this kind of programming is a bit puzzling to me (just have a look to my code ;-) ). Well, I'll have to revisit Qt examples and get familiar to signals and slots outside the main window of my application. Regards,
    • SOLVED QTcpSocket/QMQTT - Strange Error Codes
      General and Desktop • network qtcpsocket mqtt • • g.hirsch  

      4
      0
      Votes
      4
      Posts
      1595
      Views

      I saw this old thread of mine and remembered, that the issue was solved. Just writing to explain how I solved it. The problem was in the proxy settings. People who had their proxy configuration to automatic could connect, everyone else could not. First solution was to set the configuration to automatic on every client. Which was cumbersome and seemed stupid, because the program does not need any proxy. A little later I found out, that there was a problem with the Qt Network Interface, it was a known bug and could be worked around by telling the program manually to not use any proxy: /* call before connecting to network. Easiest way is, just call somewhere at the beginning of the program */ QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
    • UNSOLVED QTcpSocket state always connected
      General and Desktop • qtcpsocket client • • Gianluca86  

      23
      0
      Votes
      23
      Posts
      8469
      Views

      @puzzled_giraffe QTcpsocket have not got "connectState" setup? I think qt use long tcp connection by default.
    • UNSOLVED read and write to qtcpsocket using qdatastream
      General and Desktop • qtcpsocket qdatastream • • CybeX  

      3
      0
      Votes
      3
      Posts
      8270
      Views

      I've posted an answer how to know if you have read everything here: https://stackoverflow.com/a/46162082/969016
    • UNSOLVED writing to QTcpSocket does not always emit readyRead signal on opposite QTcpSocket
      General and Desktop • qt 5.7 qtcpsocket qtcpserver signals & slots signal&slot • • CybeX  

      3
      0
      Votes
      3
      Posts
      1531
      Views

      Isn't this the same issue as here https://forum.qt.io/topic/75821/qabstractsocket-unknownsocketerror-provides-errorstring-of-unknownerror?
    • SOLVED QTcpServer handling multiple clients asynchronously
      General and Desktop • qtcpsocket qtcpserver qthreadpool • • Kelvin Royal  

      8
      0
      Votes
      8
      Posts
      5250
      Views

      @kshegunov thank you very much really appreciate you taking your time to explain all this to me. And your are right. as soon as i connected both disconnect signals to the deleteLater() and went down the signals and slots road all the problems vanished. Thank you really. Because i had alot of time to spare i also followed @herlarbee suggestion(even though i watched this videos already) then decided to write a seperate server using QThreadPool approach seen on in the video title "Qt TCP Server design revisited". Then i benchmarked both. This new server after doing some benchmark test using ab tool in apache seems to outperform my previous solutions and handles alot more connections faster. Right now am very happy. When asking this question i just had 200 client limit in my brain but i got solutions that go way beyond that. Thank you guys. Cheers !!!
    • Block GUI when waiting for QTcpSocket data
      General and Desktop • qtcpsocket networking • • FredT  

      3
      0
      Votes
      3
      Posts
      1041
      Views

      I agree with stack overflow. Your design is flawed. The state machine behind the communication should not depend in any way on the interface
    • UNSOLVED simple chat in console application does not send data
      Mobile and Embedded • qtcpsocket qtcpserver • • MhM93  

      1
      0
      Votes
      1
      Posts
      727
      Views

      No one has replied

    • UNSOLVED Clarification....is it good or not ?
      General and Desktop • qtcpsocket qtcpserver • • billy.N  

      5
      0
      Votes
      5
      Posts
      1303
      Views

      Hi, There's also the Chat Example that may be of use.
    • UNSOLVED Set custom socket on QNetworkAccessManager request
      General and Desktop • qtcpsocket qnetworkaccessm qnetwork socks4 winsock • • eventhorizon99  

      2
      0
      Votes
      2
      Posts
      1102
      Views

      Hi and welcome to devnet, Maybe QNetworkProxy might something. Hope it helps
    • SOLVED SSL failure / certificate problem
      General and Desktop • qtcpsocket ssl qtcpserver qssl cipher • • onek24  

      2
      0
      Votes
      2
      Posts
      2173
      Views

      Fixed the problem: On Client-Side and on Server-Side i provide the following: Private key of the certificate Public key of the certificate Public key of the CA An connection is established. I am getting an SSLError: "The certificate is self-signed and untrusted", but i can either ignore it using ignoreSslErrors(); or the better method is by comparing the certificates to make sure it's all good. Also i have re-created my certificates and my CA with the correct information, because I haven't provided the CN for localhost since i was testing on my local machine with my old certificates. Anyways, the communication works with correct certificates.
    • UNSOLVED TCP Server - Client connection error with WinRT
      General and Desktop • qtcpsocket qtcpserver winrt • • beecksche  

      1
      0
      Votes
      1
      Posts
      595
      Views

      No one has replied

    • UNSOLVED QTcpSocket Connection Problem from Different Compiler?
      General and Desktop • qtcpsocket mingw qtcpserver qt 5.5.1 msvc x64 • • cemaldemir07  

      12
      0
      Votes
      12
      Posts
      4369
      Views

      @cemaldemir07 said: I think the solution is using x64 for more stable but not exact solution. No. If you have a bug in the 32 bit version, switching to 64 bits will not change that. You need to apply yourself, find the problem and ultimately fix it.
    • UNSOLVED BASIC THREADING
      General and Desktop • qthread qtcpsocket threading • • shrey  

      2
      0
      Votes
      2
      Posts
      927
      Views

      Hi and welcome to devnet, Are you also new to coding ? If so, then don't start with threads, that's a pretty complex subject that you should take on later after getting the basics correctly. Also, for what you described there's no need for threads. Qt's asynchronous nature already provide what's needed. Start with Qt's documentation. It also contains the Threading Basics On a side note, it's Qt, QT stands for Apple QuickTime which you might also be interested in.
    • SOLVED How to disable connection timer in QTcpSocket
      General and Desktop • qtcpsocket qtimer networking • • YuriQ  

      3
      0
      Votes
      3
      Posts
      1761
      Views

      @SGaist you should have to modify QAbtractSocket Seems like you right. The code in 'qabstractsocket.cpp': <...skipped...> // Start the connect timer. if (threadData->hasEventDispatcher()) { if (!connectTimer) { connectTimer = new QTimer(q); QObject::connect(connectTimer, SIGNAL(timeout()), q, SLOT(_q_abortConnectionAttempt()), Qt::DirectConnection); } connectTimer->start(QT_CONNECT_TIMEOUT); } <...skipped...> And there are no options to disable it. But I think it will be easy to patch it to make it work without connectTimer. But use a single timeout for thought of sockets ? Sounds strange. What else can I do to avoid handles exhaustion? I don't see any other options. Out of curiosity, why do you need so many sockets ? Just testing Qt abilities and limitations in this particular area.
    • UNSOLVED <Solved> TCP client read wrong data from server
      General and Desktop • qtcpsocket qtcpserver • • Vitek  

      4
      0
      Votes
      4
      Posts
      1094
      Views

      Nice you found out and thanks for sharing :) There's no need to modify the title anymore to mark the thread as solved, you can use the "Topic Tool" button for that :)
    • UNSOLVED Can't understand the reasons behind complaints; "QAudioInput: failed to set input volume" and "Got a buffer underflow!"?
      General and Desktop • qtcpsocket qaudioinput qaudiooutput • • faisal.tum  

      11
      0
      Votes
      11
      Posts
      4132
      Views

      I'd say probably, but right now I don't know what might be interfering here to trigger that message.
    • SOLVED 'Garbage at the end of the document' error on parsing QJsonDocument
      General and Desktop • qtcpsocket serialization qjsondocument qjsonobject • • returnx  

      12
      0
      Votes
      12
      Posts
      7395
      Views

      @returnx Ok. super. please mark as solved :) Final note: When you deploy, there might be more reads for full json string. The code you shown, will try to parse on each read. Make sure the code can handle that it comes in blocks and not bail out if parse fails.
    • UNSOLVED Connection delay for QTcpSocket/QTcpServer
      General and Desktop • qtcpsocket qtcpserver delay connection ports • • Mark81  

      1
      0
      Votes
      1
      Posts
      681
      Views

      No one has replied

    • UNSOLVED QTcpSocket with static local port: extremely quick SocketTimeoutError
      General and Desktop • qtcpsocket • • charango  

      1
      0
      Votes
      1
      Posts
      824
      Views

      No one has replied

    • UNSOLVED Static port for QTcpSocket
      General and Desktop • qtcpsocket port • • reezeus  

      3
      0
      Votes
      3
      Posts
      1247
      Views

      A TCP/IP connection utilizes two ports, the one you connect to on the remote end and a local port that is used for incoming data. The local port is an ephemeral port assigned by the operating system from the pool of free ephemeral port numbers. This is normal operation, you do not need to have a fixed local port because the the ephemeral port is sent to the remote end so that it knows how to reply to you the client. QAbstractSocket::peerPort() returns the remote port number.
    • SOLVED How to delete QTcpSocket properly
      General and Desktop • network qtcpsocket • • YuriQ  

      5
      0
      Votes
      5
      Posts
      7286
      Views

      The code is good but the comment is false, it's not the parent that will delete socket, it's the event loop at the next occasion.