您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1.2 KiB

Understanding the Connection State Machine

It's important to at least understand how transitions occur in the connection state machine so you make decisions depending on what triggered each state. And to understand the subtle differences depending if you are Connecting to another host or if you simply want to Listen for incoming connections. As you can see below the state machine for the NetworkConnection is pretty simple.

ConnectionState

All connections start in Disconnected state.

  • Depending what state the NetworkDriver is in, the Listening (Passive) state might be triggered. This is when the driver acts like a server listening for incoming connections and data requests. And secondly you could try to use the driver to connect to a remote endpoint and then we would invoke another flow of the state machine.

So to give a overview we have two standard scenarios. Either you listen for incoming connections or you use and outgoing connection to connect to someone else.

In our client/server workflow we use the ServerBehaviour to Listen and the ClientBehaviour to Connect.

Back to table of contents