Qt-interest Archive, July 2007
QTcpSocket to remote TCP socket without any TCP server
Message 1 in thread
Good afternoon,
My team needs to check an embedded system (target) state from a workstation
(host). To do this, we need to create a TCP connection to the target.
The problem is that our target doesn't run any TCP server; it just opens a
TCP socket and read/write into it.
1. Could it be possible to just create a QTcpSocket within our host Qt
application and communicate with our target?
2. Does the void QAbstractSocket::connectToHost ( const QHostAddress &
address, quint16 port, OpenMode openMode = ReadWrite ) API still suit to set
the address and port of the QTcpSocket on the host side, even if there isn't
any TCP server running on our target?
I hope I've been clear enough to make myself understood, thank you.
Christophe
--
[ signature omitted ]
Message 2 in thread
On Monday 09 July 2007 09:06, Christophe Bismuth wrote:
> The problem is that our target doesn't run any TCP server; it just opens a
> TCP socket and read/write into it.
What's the difference?
> 1. Could it be possible to just create a QTcpSocket within our host Qt
> application and communicate with our target?
Sure, the target doesn't have to be using Qt, it just has to speak TCP.
--
[ signature omitted ]
Message 3 in thread
Thank you for your reply. I'm sorry for answering a little bit late, but my
Internet connection is very limited at work...
To be more precise, my question is:
1. The target will open a TCP socket to the host address and port 5000,
2. The host will open a TCP socket to the target address and port 5000,
Will they be able to exchange data even though no TCP server has created a
connection between them?
Is a TCP server always needed to init the connection or could a direct
connection be enough?
Thank you,
Christophe
"Simon Perreault" <nomis80@xxxxxxxxxxx> a écrit dans le message de news:
200707090917.15515.nomis80@xxxxxxxxxxxxxx
> On Monday 09 July 2007 09:06, Christophe Bismuth wrote:
>> The problem is that our target doesn't run any TCP server; it just opens
>> a
>> TCP socket and read/write into it.
>
> What's the difference?
>
>> 1. Could it be possible to just create a QTcpSocket within our host Qt
>> application and communicate with our target?
>
> Sure, the target doesn't have to be using Qt, it just has to speak TCP.
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]
Message 4 in thread
On Monday 09 July 2007 10:10, Christophe Bismuth wrote:
> 1. The target will open a TCP socket to the host address and port 5000,
> 2. The host will open a TCP socket to the target address and port 5000,
No, that won't work. There has to be a server to answer the client's
connection, otherwise the connect call will fail. If you don't want to put a
server in the target, you could put the server in the host instead.
--
[ signature omitted ]
Message 5 in thread
Thank you Simon.
If I start a QTcpServer on the host side, could this server be able to
read/answer the target messages?
I can't find any Qt API to do this. With a QTcpSocket I'm used to calling
readAll and write.
"Simon Perreault" <nomis80@xxxxxxxxxxx> a écrit dans le message de news:
200707091020.08472.nomis80@xxxxxxxxxxxxxx
> On Monday 09 July 2007 10:10, Christophe Bismuth wrote:
>> 1. The target will open a TCP socket to the host address and port 5000,
>> 2. The host will open a TCP socket to the target address and port 5000,
>
> No, that won't work. There has to be a server to answer the client's
> connection, otherwise the connect call will fail. If you don't want to put
> a
> server in the target, you could put the server in the host instead.
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]
Message 6 in thread
On Monday 09 July 2007 10:53, Christophe Bismuth wrote:
> If I start a QTcpServer on the host side, could this server be able to
> read/answer the target messages?
Yes. The host will be the server and the target will be the client.
Afterwards, it's just standard TCP client/server programming. Have a look at
the TCP client/server examples:
http://doc.trolltech.com/4.3/network-fortuneclient.html
http://doc.trolltech.com/4.3/network-fortuneserver.html
Good luck!
--
[ signature omitted ]
Message 7 in thread
Thank you Simon for your advice, it was very relevant.
1. Everything works fine now when I test with QHostAddress::LocalHost as the
target address (my computer is both host & target).
2. But when I try to use the real target address, the TCP server can't
listen to it...
Note: IP, Mask & Gateway of the host (my computer) are set and I can ping
the target (the embedded system) with the Windows command line.
The Trolltech documentation doesn't say why QTcpServer::listen() API could
fail... Does anyone has an idea ?
Christophe
"Simon Perreault" <nomis80@xxxxxxxxxxx> a écrit dans le message de news:
200707091059.16423.nomis80@xxxxxxxxxxxxxx
> On Monday 09 July 2007 10:53, Christophe Bismuth wrote:
>> If I start a QTcpServer on the host side, could this server be able to
>> read/answer the target messages?
>
> Yes. The host will be the server and the target will be the client.
> Afterwards, it's just standard TCP client/server programming. Have a look
> at
> the TCP client/server examples:
>
> http://doc.trolltech.com/4.3/network-fortuneclient.html
> http://doc.trolltech.com/4.3/network-fortuneserver.html
>
> Good luck!
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]
Message 8 in thread
Everything works, I've made a mistake while setting host & target IP's.
Thank you very much Simon :o)
Bye,
Christophe
"Christophe Bismuth" <christophe.bismuth@xxxxxxxxx> a écrit dans le message
de news: f780h5$hkk$1@xxxxxxxxxxxxxxxxxxxxx
> Thank you Simon for your advice, it was very relevant.
>
> 1. Everything works fine now when I test with QHostAddress::LocalHost as
> the target address (my computer is both host & target).
>
> 2. But when I try to use the real target address, the TCP server can't
> listen to it...
> Note: IP, Mask & Gateway of the host (my computer) are set and I can ping
> the target (the embedded system) with the Windows command line.
>
> The Trolltech documentation doesn't say why QTcpServer::listen() API could
> fail... Does anyone has an idea ?
>
> Christophe
>
> "Simon Perreault" <nomis80@xxxxxxxxxxx> a écrit dans le message de news:
> 200707091059.16423.nomis80@xxxxxxxxxxxxxx
>> On Monday 09 July 2007 10:53, Christophe Bismuth wrote:
>>> If I start a QTcpServer on the host side, could this server be able to
>>> read/answer the target messages?
>>
>> Yes. The host will be the server and the target will be the client.
>> Afterwards, it's just standard TCP client/server programming. Have a look
>> at
>> the TCP client/server examples:
>>
>> http://doc.trolltech.com/4.3/network-fortuneclient.html
>> http://doc.trolltech.com/4.3/network-fortuneserver.html
>>
>> Good luck!
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
>> "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]