Communication state defines the states in which a communication-oriented object can exist.

These states are defined as enumerations in the System.ServiceModel.dll.

 

http://msdn.microsoft.com/en-us/library/system.servicemodel.communicationstate(v=vs.110).aspx defines the various names in the enumeration however we do not get to see the enumeration values.

As the above link explains there are four main states that a communication-oriented object can exist. They are:

  • Created
  • Opened
  • Closed
  • Faulted

The transitory states of the communication-oriented object are:

  • Opening
  • Closing

The various state diagrams are shown below.

 

 (Image from http://msdn.microsoft.com/en-us/library/ms789041(v=vs.110).aspx )

The enumeration is actually defined as:

 

public enum CommunicationState

{

    Created,

    Opening,

    Opened,

    Closing,

    Closed,

    Faulted

}

 

So Created = 0, Opening = 1 and so forth.

Please refer to http://msdn.microsoft.com/en-us/library/ms789041(v=vs.110).aspx for a complete understanding of the state machines.