How to assign static IP address and disable DHCP

swaroop2011:
I was just reading TCP vs UDP,
isn't the communication via UDP unsafe ?
And above that there are high chances of error ?

UDP is a "best effort" protocol to send packets of data from one node to another. By best effort, it means it will try to send a packet, but there are no assurances that the packet will actually be received properly (or at all) by the destination node. Packets could get lost for a variety of reasons, or they might be duplicated,mor in a complicated enough network they could arrive out of order. The advantage is that it's a rather low overhead protocol.

TCP adds a layer of control over UDP. It still sends packets of data, but the destination node sends information back about what it has and has not received properly. This allows the sender to retransmit data as needed. TCP offers guaranteed delivery of a stream of data. You don't have control over how that data will be received as packets, but all of the data will get there.

They both have their uses: TCP is good when every byte needs to get there in the right order, but the timing between bytes and the start/end of individual transmissions does not need to be preserved. UDP is good when the boundaries of a packet of data must be preserved, but it's acceptable to occasionally lose a packet.

Consider a system that repeatedly sends a block of current sensor data. This is a good use of UDP because there is a lot of redundant data, and it's low overhead. Because packet boundaries are preserved,mist easy to parse the data. If one packet is lost, another will be received soon, so it's probably not a serious problem. However, if you don't want to keep sending all the sensor data every time, but just the changes, then TCP is better because losing one of the change notifications would be very serious. But you need a bit more care in preparing and parsing data to add delimiters where each update begins and ends.

Can't we do TCP, using the same setup as explained in 1st post (ethernet wire + Switch ) ?

Yes, you can. UDP makes for a simpler example for a test case and it's code is smaller and easier to understand. It's offered as a simple example, not as the only possibility. Once you have the addressing and wiring working properly, you can use just about any networking protocol.