Check out example codes for "socket program to timeout in java". It will help you in understanding the concepts better.

Code Example 1

socket.setSoTimeout(10*1000);

Learn ReactJs, React Native from akashmittal.com