Skip to main content

Connection Time out Vs Socket Time out

Time out
Any client(or source) which is unable to connect to the server (or Destination) in a specified time, then requests will automatically gets time outs.

Port
Port numbers allow different applications on the same computer to utilize network resources without interfering with each other. Port numbers most commonly appear in network programming, particularly socket programming. Sometimes, though, port numbers are made visible to the casual user. For example, some Web sites a person visits on the Internet use a URL like the following:

http://www.appdomain.in:80/ In this example, the number 80 refers to the port number used by the Web browser to connect to the Web server. Normally, a Web site uses port number 80 and this number need not be included with the URL (although it can be).

Port 80 is the default port for HTTP

Socket
Each and every communication from one application to another application should happen through sockets. Socket is gateway to send/receive information from one application to another.

A TCP socket is not a connection, it is the endpoint of a specific connection.
Every connection between a client and server requires a unique socket.
Applications can create multiple sockets for communicating with each other.
Sockets are bidirectional, meaning that either side of the connection is capable of both sending and receiving data

A socket contains following parameters

    An IP address
    A transport protocol
    A port number

A socket = Transport protocol + IP Address + a port (numeric address)   


   
Connection Time out Vs Socket Time out

Connection time outs will occur when requests are not able to reach remote machine on the specified
Host name/IP on specified port number under specified time.

So this Connection time outs can occur or can be simulated
1.By providing the incorrect host names or Port numbers.
2.By providing the time out period which is less than the actually it takes.
  This has to set at the code level while we creating the connection.

Socket time out will occur when requests are not able to reach the application which is running in local or remote machines.

So this socket time outs
1. By providing the time out period which is less than the requests actually takes.
2. Shut down the application which client is trying to connect.

Comments

Popular posts from this blog

Spring Reactive Stack

Compress a String

package com.sbs.java8.praticse; public class StringCompression { public StringCompression() { // TODO Auto-generated constructor stub } public static void main(String[] args) { System.out.println(compressString("aaaabbbbbccccAAAAccccccccdefg")); } public static String compressString(String str) { //String str = "aaaabbbbbcccc"; char[] charArray = str.toCharArray(); String compressedString = ""; int i = 0; while (i < charArray.length) { int counter = 1; int j = i + 1; while (j < charArray.length && charArray[i] == charArray[j]) { counter++; j++; i++; } compressedString = compressedString + charArray[i] + counter; i++; } //System.out.println(compressedString); String output =(compressedString.length() > charArray.length)? str: compressedString; return output; } }

Basic Sortings (Bubble, Selection and Insertion Sorts)

public class BasicSortings { public static void main(String[] args) { int temp; int iterationCount = 0; int array[] = { 2, 33, 29, 30, 21, 98}; //Bubble sort or Simple sort for (int i = 0; i < array.length - 1; i++) { for (int j = i + 1; j < array.length; j++) { if (array[i] > array[j]) { temp = array[i]; array[i] = array[j]; array[j] = temp; } iterationCount++; } } System.out.println("Bubble Sort Big 0(n) --> " + iterationCount); for (int s = 0; s < array.length; s++) { System.out.print(array[s] + "\t"); } System.out.println("\n"); System.out.println("\n"); //Selection Sort iterationCount =0; int sortPointer=0; for (int i = sortPointer; i < array.length; i++) { for(int j=i+1;j< array.length;j++) { if(array[i] > array[j]) { temp = array[i]; array[i] = array[j]; array[j] = temp;