<?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[how to comunicate with not-qt procedure?]]></title><description><![CDATA[<p dir="auto">i write a demo for tcp communicate between qt and not-qt.</p>
<p dir="auto">qt:</p>
<pre><code>   _tcpSocket  = _tcpserver-&gt;nextPendingConnection();
  //  _tcpserver -&gt;close();                         

   QByteArray block;
   QDataStream out(&amp;block,QIODevice::WriteOnly);

   out.setVersion(QDataStream::Qt_5_7);
   out&lt;&lt;tr("i have get your requst");

   _tcpSocket-&gt;write(block);

</code></pre>
<p dir="auto">not-qt:<br />
sock_fd = socket(AF_INET, SOCK_STREAM, 0);<br />
if(sock_fd &lt; 0)<br />
{<br />
syslog(LOG_ERR, "%s:%d, create socket failed", <strong>FILE</strong>, <strong>LINE</strong>);<br />
exit(1);<br />
}<br />
if(connect(sock_fd, (struct sockaddr *)&amp;ser_addr, sizeof(ser_addr)) &lt; 0)<br />
{<br />
syslog(LOG_ERR, "%s:%d, connect socket failed", <strong>FILE</strong>, <strong>LINE</strong>);<br />
exit(1);<br />
}<br />
//receive data<br />
recvlen = 0;<br />
retlen = 0;<br />
ptr = recvbuf;<br />
leftlen = RECV_BUF_SIZE -1;<br />
//do<br />
{<br />
retlen = recv(sock_fd, ptr, leftlen, 0) ;<br />
if(retlen &lt; 0)<br />
{<br />
if(errno == EINTR)<br />
retlen = 0;<br />
else<br />
exit(1);<br />
}<br />
recvlen += retlen;<br />
leftlen -= retlen;<br />
ptr += retlen;<br />
}<br />
//while(recvlen &amp;&amp; leftlen);<br />
printf("receive data is : %s", recvbuf);</p>
<p dir="auto">no-qt run on linux like this ./client;<br />
but recvbuf is null.<br />
how can i get the right data("i have get your requst")? thank for your help</p>
]]></description><link>https://forum.qt.io/topic/73214/how-to-comunicate-with-not-qt-procedure</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 13:14:39 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/73214.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 Nov 2016 12:26:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to how to comunicate with not-qt procedure? on Fri, 11 Nov 2016 07:43:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chaochao">@<bdi>chaochao</bdi></a><br />
Np. If it works sending as raw. Please notice you might get issues if you send from very<br />
different platforms. ( the Endianness ) Might not be issue in your use case.</p>
]]></description><link>https://forum.qt.io/post/359008</link><guid isPermaLink="true">https://forum.qt.io/post/359008</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Fri, 11 Nov 2016 07:43:01 GMT</pubDate></item><item><title><![CDATA[Reply to how to comunicate with not-qt procedure? on Fri, 11 Nov 2016 07:36:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> very thanks</p>
]]></description><link>https://forum.qt.io/post/359006</link><guid isPermaLink="true">https://forum.qt.io/post/359006</guid><dc:creator><![CDATA[chaochao]]></dc:creator><pubDate>Fri, 11 Nov 2016 07:36:16 GMT</pubDate></item><item><title><![CDATA[Reply to how to comunicate with not-qt procedure? on Fri, 11 Nov 2016 07:19:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chaochao">@<bdi>chaochao</bdi></a><br />
Well I would just skip header<br />
once full data have been read.<br />
Its very fast. ptr += headerlength;</p>
<p dir="auto">Also please notice that the stream also controls byteorder so if you send between differnt<br />
platforms, there might be something more to handle.<br />
<a href="https://en.wikipedia.org/wiki/Endianness" target="_blank" rel="noopener noreferrer nofollow ugc">https://en.wikipedia.org/wiki/Endianness</a></p>
<p dir="auto">Also there is another rawwrite that writes the data unmodified.<br />
<a href="http://doc.qt.io/qt-5/qdatastream.html#writeRawData" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qdatastream.html#writeRawData</a><br />
"Writes len bytes from s to the stream. Returns the number of bytes actually written, or -1 on error. <strong>The data is not encoded.</strong>"</p>
<p dir="auto">Might be better for your use case.</p>
]]></description><link>https://forum.qt.io/post/359003</link><guid isPermaLink="true">https://forum.qt.io/post/359003</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Fri, 11 Nov 2016 07:19:36 GMT</pubDate></item><item><title><![CDATA[Reply to how to comunicate with not-qt procedure? on Fri, 11 Nov 2016 05:26:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> thank you ,i did it by tcpdump.like you say,the is a data-header and the data has their own dormat.</p>
<p dir="auto">00:00:00:2c:<br />
0-3 header</p>
<p dir="auto">00:69: i<br />
00:20: ' '<br />
00:68:00:61:00:76:00:65: have</p>
<p dir="auto">00:20:' '<br />
00:67:00:65:00:74:      get<br />
00:20:' '<br />
00:79:00:6f:00:75:00:72:  your<br />
00:20:' '<br />
00:72:00:65:00:71:00:75:00:73:00:74 requst</p>
<p dir="auto">4 bytes header. and one character has been transfer by tow <a href="http://bytes.is" target="_blank" rel="noopener noreferrer nofollow ugc">bytes.is</a> there a more efficient way to resolve the qt datastream on no-qt precedure?</p>
]]></description><link>https://forum.qt.io/post/358990</link><guid isPermaLink="true">https://forum.qt.io/post/358990</guid><dc:creator><![CDATA[chaochao]]></dc:creator><pubDate>Fri, 11 Nov 2016 05:26:05 GMT</pubDate></item><item><title><![CDATA[Reply to how to comunicate with not-qt procedure? on Thu, 10 Nov 2016 14:36:51 GMT]]></title><description><![CDATA[<p dir="auto">Ok<br />
So you are 100% sure client can read from a server ?<br />
It should also work with Qt then.</p>
<p dir="auto">You are using a DataStream and it might include some header. Since you are not<br />
using a DataStream in other end , it might give something unexpected results.</p>
<p dir="auto">You could  use a tcp sniffer and see what it actually writes.</p>
]]></description><link>https://forum.qt.io/post/358901</link><guid isPermaLink="true">https://forum.qt.io/post/358901</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Thu, 10 Nov 2016 14:36:51 GMT</pubDate></item><item><title><![CDATA[Reply to how to comunicate with not-qt procedure? on Thu, 10 Nov 2016 13:32:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a>  i have tried this client procedure on linux. the server you mentioned is writed with unix network.```<br />
int sfd,cfd;<br />
struct sockaddr_in saddr,caddr;<br />
int socklen = sizeof( struct sockaddr_in);</p>
<p dir="auto">memset(&amp;saddr,0,sizeof(struct sockaddr_in));<br />
memset(&amp;caddr,0,sizeof(struct sockaddr_in));</p>
<p dir="auto">saddr.sin_family = AF_INET;<br />
saddr.sin_port = htons(4567);<br />
saddr.sin_addr.s_addr = htonl(INADDR_ANY);</p>
<p dir="auto">sfd = socket(AF_INET, SOCK_STREAM, 0);<br />
bind(sfd, (struct sockaddr *)&amp;saddr, sizeof( struct sockaddr_in)) ;<br />
listen(sfd, 5)</p>
<p dir="auto">while(1)<br />
{<br />
unsigned char rbuffer[20]={0};<br />
unsigned char sbuffer[]="i have recived your request\n";</p>
<pre><code>    cfd = accept(sfd, (struct sockaddr *)&amp;caddr, &amp;socklen); 
    send(cfd,sbuffer,strlen(sbuffer),0);

	recv(cfd, rbuffer, 20, 0) ; 

	printf("reply is %s\n",rbuffer);
}
</code></pre>
<p dir="auto">return 0;</p>
<pre><code></code></pre>
]]></description><link>https://forum.qt.io/post/358893</link><guid isPermaLink="true">https://forum.qt.io/post/358893</guid><dc:creator><![CDATA[chaochao]]></dc:creator><pubDate>Thu, 10 Nov 2016 13:32:06 GMT</pubDate></item><item><title><![CDATA[Reply to how to comunicate with not-qt procedure? on Thu, 10 Nov 2016 12:34:27 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
Maybe you should make a small ./testserver using native calls also , so you<br />
can check if your client code do work. When they can talk (and send),<br />
you can try with Qt as server.</p>
]]></description><link>https://forum.qt.io/post/358879</link><guid isPermaLink="true">https://forum.qt.io/post/358879</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Thu, 10 Nov 2016 12:34:27 GMT</pubDate></item></channel></rss>