PDA

View Full Version : create udp server for non Qt client



kalyanakumarr
15th October 2010, 17:08
My project requires writing a UDP server in Qt for NonQt clients.
In examples I read all are tell how to implement server and client both in Qt.
Please guide me how to go about.

Lykurg
15th October 2010, 17:13
My project
we wont do your homework...

requires writing a UDP server in Qt for NonQt clients.
In examples I read all are tell how to implement server and client both in Qt.
Please guide me how to go about.
:confused: Isn't UDP server telling by its own that the server and the client coresponding via UDP? And I have never heard that UDP is Qt only.

kalyanakumarr
15th October 2010, 17:41
In the implementation of server by QUdpSocket based examples we are creating ByteArray buffer object, then use QDataStream device object with write only and passing the ByteArray, then we are setting version of QDataStream, then use << operator to send the data which is of type double to the ByteArray buffer. Then we are calling the writedatagram by passing ByteArray buffer, host address and port number.
The doubt to be clarified (not to do my homwork) is will a non qt application understand the byte order done by QDataStream? Thanks in advance.

tbscope
15th October 2010, 17:48
The doubt to be clarified (not to do my homwork) is will a non qt application understand the byte order done by QDataStream? Thanks in advance.

QDataStream is Qt specific. If you have a non Qt program, you need to implement the QDataStream structure in that application.

However, you do not need to use QDataStream.

kalyanakumarr
15th October 2010, 18:21
QDataStream is Qt specific. If you have a non Qt program, you need to implement the QDataStream structure in that application.

However, you do not need to use QDataStream.

Thanks a lot. I understood now that without using QDataStream itself this could be achived. Directly fill the QByteArray object and then pass the same to writedatagram function. Thanks a lot for sharing your experience.

squidge
15th October 2010, 19:25
Well, since your other program will be receiving the data anyway, why not just try? You will quickly work out if you can parse the packets or whether you need to design your own QDataStream.

kalyanakumarr
2nd January 2011, 12:18
We wrote the functions to write each type of the data(both common type and struct) in to a charArray in terms of the bytes based on pointer arithmetics.
Use the Qt Udp function calls which takes char Array and its size.
The Program worked fine.

For confirming the data is sent or not we used the tcpdump utility.

Thanks a lot.