We have seen how to write a simple UDP socket program in C (Linux) in the earlier post..
In the following example we used to send and receive data on localhost address.
And the readyRead() signal and slot is used whenever the data receives on the given socket (i.e. socket reday for read data), the control goes to slot method.
writeDatagram() and readDatagram() API's used for sending and receiving data on the given udp socket.
Now we are going to learn how to write a simple UDP socket program in Qt..
In the following example we used to send and receive data on localhost address.
And the readyRead() signal and slot is used whenever the data receives on the given socket (i.e. socket reday for read data), the control goes to slot method.
writeDatagram() and readDatagram() API's used for sending and receiving data on the given udp socket.
Before starting the Program to write, create a Project using following steps
- open Qt creator
- Create Project
- Select Other Project in Projects tab then select Qt Console Application, then click on choose...
- Then give the Project name
- And then click on Next, Finish in the following dialog boxes
- Then open the .pro file and write QT += network
- To create the cpp file Right click on the project then choose Add new