Here we will make a simple chat app that will allow 2 IP’s to communicate with each other. For this we will use the UDP protocol.
User Datagram Protocol (UDP) is a Transport Layer protocol. UDP is a part of Internet Protocol suite, referred as UDP/IP suite. Unlike TCP, it is unreliable and connectionless protocol. So, there is no need to establish connection prior to data transfer. However the advantage of UDP over TCP is that it is fast as compared to TCP as no ack. is required.
A socket is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to.
For this task we will use socket programming which will include port binding.
However socket programming alone can’t do the required task so we need to implement other programming concept known as “multithreading”.
Multithreading is a type of execution model that allows multiple threads to exist within the context of a process such that they execute independently but share their process resources. A thread maintains a list of information relevant to its execution including the priority schedule, exception handlers, a set of CPU registers, and stack state in the address space of its hosting process.
Multithreading is also known as threading.
For this task one IP is of windows computer and other IP is of linux computer(Redhat)
As we have imported threading and socket module and here we have bind ip and port number and threading is done.The code will remain same in both the IP’s.
As in this code only IP and ports are interchanged.
Now lets run the program
As you can see the code is running and the 2 IP’s are communicating with each other.
Hence the task is completed.
The biggest challenge I faced was that the process was not reliable as you can see i have set the limit to 1024 which means only this much letters can be transmitted through this app, so if someone tries send more than 1024 letters it will fail and the receiver won’t be able to get the message and the sender won’t know that.
1 So the process is not reliable.
2 It is very difficult to fix the bug if any appeared in this case.