<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Using UDP multi client with single server how to do?]]></title><description><![CDATA[<p dir="auto">if client 1 : sends "Test1" to server and reply back to client "Reply1".</p>
<p dir="auto">if client 2 : sends "Test2" to server and reply back to client "Reply2".</p>
<p dir="auto">if any one know please help me. i have done using TCP but not with UDP.</p>
]]></description><link>https://forum.qt.io/topic/93999/using-udp-multi-client-with-single-server-how-to-do</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 04:18:56 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/93999.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 24 Aug 2018 08:32:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Using UDP multi client with single server how to do? on Sat, 25 Aug 2018 06:32:49 GMT]]></title><description><![CDATA[<p dir="auto">Here i am testing in single computer. so i thought local host means 127.0.0.1?</p>
]]></description><link>https://forum.qt.io/post/478103</link><guid isPermaLink="true">https://forum.qt.io/post/478103</guid><dc:creator><![CDATA[bhargav]]></dc:creator><pubDate>Sat, 25 Aug 2018 06:32:49 GMT</pubDate></item><item><title><![CDATA[Reply to Using UDP multi client with single server how to do? on Sat, 25 Aug 2018 05:52:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bhargav">@<bdi>bhargav</bdi></a> said in <a href="/post/478094">Using UDP multi client with single server how to do?</a>:</p>
<blockquote>
<p dir="auto">serudpSocket-&gt;writeDatagram(clientData, QHostAddress::LocalHost, port );</p>
</blockquote>
<p dir="auto">you are sending to <code>QHostAddress::LocalHost</code> instead of <code>sender</code></p>
]]></description><link>https://forum.qt.io/post/478100</link><guid isPermaLink="true">https://forum.qt.io/post/478100</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Sat, 25 Aug 2018 05:52:48 GMT</pubDate></item><item><title><![CDATA[Reply to Using UDP multi client with single server how to do? on Sat, 25 Aug 2018 05:50:48 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui-&gt;setupUi(this);

    setWindowTitle("Server App");

    serudpSocket = new QUdpSocket();

    serudpSocket-&gt;bind(QHostAddress::Any, 6000);

    connect(serudpSocket, SIGNAL(readyRead()), this, SLOT(readingmsg()));

    connect(serudpSocket, SIGNAL(disconnected()), this, SLOT(deleteLater()));


}

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

void MainWindow::readingmsg()
{

        // reading from client
        QByteArray buffer;

        buffer.resize(serudpSocket-&gt;pendingDatagramSize());

        QHostAddress sender;
        quint16 port;

        qDebug()&lt;&lt;"port in reading:"&lt;&lt;port;

        serudpSocket-&gt;readDatagram(buffer.data(),buffer.size(),&amp;sender,&amp;port);

        ui-&gt;textEdit-&gt;setText(buffer);


        // Writing to the client,need to specify the client port number.

  //      static int i;
        QByteArray clientData;

        QString str = "reply";

//        QString index = QString::number(i);

        clientData.append(str);

        serudpSocket-&gt;writeDatagram(clientData, QHostAddress::LocalHost, port );

        // for debugging
        qDebug()&lt;&lt;"Datagram Recieved From client: "&lt;&lt; buffer.data();
        qDebug()&lt;&lt;"Client IP" &lt;&lt; sender.toString();
        qDebug()&lt;&lt;"port in sending:"&lt;&lt; port;
        qDebug()&lt;&lt;"Datagram sending to client:"&lt;&lt; clientData.data();
        qDebug()&lt;&lt;"\n";

      //  i++;
}
</code></pre>
<p dir="auto">this is my code help me to get desired output?</p>
<p dir="auto">multi client single server<br />
when client1 sends "test1" it has to send back "reply1"<br />
when client1 sends "test2" it has to send back "reply2"  like that ?</p>
]]></description><link>https://forum.qt.io/post/478094</link><guid isPermaLink="true">https://forum.qt.io/post/478094</guid><dc:creator><![CDATA[bhargav]]></dc:creator><pubDate>Sat, 25 Aug 2018 05:50:48 GMT</pubDate></item><item><title><![CDATA[Reply to Using UDP multi client with single server how to do? on Fri, 24 Aug 2018 12:53:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bhargav">@<bdi>bhargav</bdi></a><br />
Can you even do this with UDP??  "Send replies back"?  It makes no sense.  For one thing, the client may (well) not even receive the datagram...</p>
]]></description><link>https://forum.qt.io/post/478004</link><guid isPermaLink="true">https://forum.qt.io/post/478004</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Fri, 24 Aug 2018 12:53:34 GMT</pubDate></item><item><title><![CDATA[Reply to Using UDP multi client with single server how to do? on Fri, 24 Aug 2018 08:56:19 GMT]]></title><description><![CDATA[<p dir="auto">QTcpSocket and QUdpSocket are both <code>QIODevice</code>s so you can read/write them in the exact same way</p>
]]></description><link>https://forum.qt.io/post/477953</link><guid isPermaLink="true">https://forum.qt.io/post/477953</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Fri, 24 Aug 2018 08:56:19 GMT</pubDate></item></channel></rss>