Skip to content
  • 0 Votes
    1 Posts
    87 Views
    No one has replied
  • 0 Votes
    4 Posts
    171 Views
    Christian EhrlicherC

    @Joe-von-Habsburg said in Take message only 1 port by UDP socket receive:

    How can I ignore ?

    Look at the QHostAddress and don't process it - there is no other chance except you add some filtering on OS level but Qt can't do anything against it.

  • 0 Votes
    3 Posts
    201 Views
    C

    @Sajjad-Ali Quite apart from @JonB's observations:

    Your receiver is not listening. You need to look at QTcpServer You need to ensure that the receiving end does not have a system firewall blocking whatever port you are listening on.
  • 0 Votes
    5 Posts
    301 Views
    J

    @JonB thank you so much

  • 0 Votes
    5 Posts
    367 Views
    JonBJ

    @Narutoblaze
    Then no you cannot, as you can see in the documentation for QTcpSocket/ QAbstractSocket. If there were a method which took a "connection name" you would see it documented.

    There is nothing to stop you writing your own code to store connections indexed by some "connection name" you choose, e.g. using a QMap Class.

  • 0 Votes
    2 Posts
    418 Views
    JonBJ

    @TokaraForest
    I don't see that it will make any difference whether you stick with asynchronous approach (which does not block) in UI thread or use synchronous approach with waitFor...() in a thread (which will block that thread but not the Ui thread). Either way scanning 100 ports will take some time because each port has to have time to timeout. It will be "slow". You might as well use asynchronous and not get involved with threads if this is what you have to do.

    But why do you want to scan ports, and at which side? Client should be able to be set to use any available port to connect to server (this is fast). And server needs to specify which port it will be listening on, there is no point it finding a free one as client will not know which one it picked to connect on.

  • 0 Votes
    1 Posts
    288 Views
    No one has replied
  • 0 Votes
    1 Posts
    276 Views
    No one has replied
  • 0 Votes
    4 Posts
    3k Views
    T

    @artwaw

    Thanks a lot ! It works.

    I don't know how I could miss this one. It seems that every time I restart the server, the IP changes. I will have to set a fixed IP adress.

  • 1 Votes
    4 Posts
    636 Views
    piseprashanthP

    Basically you missed to add addHostSideConnection on server side. Here is below code snippet.

    // server side
    void onNewServerConnection()
    {
    qDebug() << "onNewServerConnection";
    bool newConn = false;
    if(auto tcpServer = qobject_cast<QTcpServer*>(sender()))
    {
    while(tcpServer->hasPendingConnections())
    {
    newConn = true;
    m_pHost->addHostSideConnection(tcpServer->nextPendingConnection());
    }
    }
    }
    // Use standard tcp url for the registry
    const QUrl registryUrl = QUrl(QStringLiteral("tcp://127.0.0.1:65212"));
    // Use "exttcp" for the "external" interface
    const QUrl extUrl = QUrl(QStringLiteral("exttcp://127.0.0.1:65213"));

    // Create the server and listen outside of QtRO // QTcpServer tcpServer; auto tcpServer = new QTcpServer(this); auto host = extUrl.host(); // We only know how to handle tcp:// and local: bool res = false; res = tcpServer->listen(QHostAddress(extUrl.host()), extUrl.port()); if(res) { // m_servers.insert(url, server); connect(tcpServer, &QTcpServer::newConnection, this, &YourClass::onNewServerConnection); } else { qWarning().nospace() << "server could not listen on URL: " << extUrl.toString() << ". Error type: " << tcpServer->serverError() << ", message: " << tcpServer->errorString(); delete tcpServer; } // We need a registry for everyone to connect to QRemoteObjectRegistryHost registry(registryUrl); // Finally, we create our host node and register "exttcp" as our schema. // We need the AllowExternalRegistration parameter to prevent the node from // setting a hostUrlInvalid error. m_pHost = new QRemoteObjectHost(extUrl, registryUrl, QRemoteObjectHost::AllowExternalRegistration); // From now on, when we call enableRemoting() from this node, the registry // will be updated to show the Source object at extUrl.

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    OnClient side
    // Use standard tcp url for the registry
    const QUrl registryUrl = QUrl(QStringLiteral("tcp://127.0.0.1:65212"));

    // This time create the node connected to the registry QRemoteObjectNode repNode(registryUrl); // Create the RemoteObjectSchemaHandler callback QRemoteObjectNode::RemoteObjectSchemaHandler setupTcp = [&repNode](QUrl url) -> void { QTcpSocket *socket = new QTcpSocket(&repNode); connect(socket, &QTcpSocket::connected, [socket, &repNode]() { qDebug() << "Added client side connection"; repNode.addClientSideConnection(socket); }); connect(socket, &QSslSocket::errorOccurred, [socket](QAbstractSocket::SocketError error) { qDebug() << "Deleted socket"; delete socket; }); qDebug() << "Connected to host with URL: " << url.host() <<":" << url.port(); socket->connectToHost(url.host(), url.port()); }; // Once we call registerExternalSchema, the above method will be called // whenever the registry sees an object we are interested in on "exttcp" repNode.registerExternalSchema(QStringLiteral("exttcp"), setupTcp); // local replica // QRemoteObjectNode repNode; // create remote object node // m_pHost = new QRemoteObjectHost(QUrl(ss.str().c_str())); // repNode.connectToNode(QUrl(ss.str().c_str())); //QUrl(QStringLiteral("local:replica"))); auto ptr = repNode.acquireDynamic("something");
  • 0 Votes
    1 Posts
    657 Views
    No one has replied
  • 0 Votes
    11 Posts
    3k Views
    SGaistS

    The edited part of @JonB is important, you have to read the data.

  • 0 Votes
    2 Posts
    336 Views
    VRoninV

    99.9999% probability you are trying to use the object you just deleted.
    If you call deleteLater on an object you then have to recreate it (e.g. with new) before using it or trying to delete it again

  • 0 Votes
    11 Posts
    2k Views
    nooneN

    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

  • 0 Votes
    4 Posts
    562 Views
    nooneN

    @JonB Thanks. I didn't know about those links. they look promising. This whole networking stuff is really new to me

    @Christian-Ehrlicher Thanks. So for large data, I guess QWebSocket::binaryFrameReceived() is the correct way

  • 0 Votes
    6 Posts
    3k Views
    VRoninV

    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"; });
  • 0 Votes
    7 Posts
    2k Views
    Pablo J. RoginaP

    @SnuggleKat said in Cannot access MySQL running on another machine:

    Looks like skip-networking solved the problem

    Could you describe what this skip-networking concept is? for the sake of completeness and benefit of documenting the case for other future users having the same issue.

    And if your issue is solved, please don't forget to mark your post as such. Thanks

  • 0 Votes
    2 Posts
    890 Views
    SGaistS

    Hi,

    You should rather bring this to the interest mailing list. You'll find there the QtRemoteObject developers/maintainers. This forum is more user oriented.

  • QFile Read Binary blockwise

    Solved General and Desktop
    2
    0 Votes
    2 Posts
    2k Views
    J.HilkJ

    Never mind,
    @tobias-hunger in this thread 6 years ago is right.

    I changed:

    qiSend = file.read(readData,iSend);

    to

    QByteArray b = file.read(iSend);

    And now I'm getting all needed bytes.

  • 0 Votes
    2 Posts
    3k Views
    C

    Hello i wish if i could help you. please i need to send voice over network using tcp socket and i believe you can help me if you give me your code (server and client side both )i will be very thankful.thank you soo much in advance.