strict digraph send_states {
  start [peripheries=2];
  end [peripheries=2];
  connection_established;
  handshake;
  send_data;
  shutdown;
  gnutls_bye;
  close_one;
  close_both;

  wait_for_connect;
  wait_for_buf;
  wait_for_eof;

  node [label="", shape="box", height=0.1, width=0.1];
  close;
  drain;
  hangup;
  hangup_unsecure;



  start -> wait_for_connect [label="duplex"];
  start -> connection_established;   

  wait_for_connect -> connection_established;
  wait_for_connect -> close [label="error"];

  connection_established -> handshake [label="tls"];
  connection_established -> send_data;

  handshake -> close [label="error"];
  handshake -> send_data;

  send_data -> close [label="error"];
  send_data -> drain [label="drain"];

  drain -> wait_for_buf;
  drain -> hangup [label="got_close"];

  wait_for_buf -> send_data;
  wait_for_buf -> drain [label="empty_buf"];

  hangup -> gnutls_bye [label="tls"]; 
  hangup -> hangup_unsecure;

  gnutls_bye -> wait_for_eof;
  gnutls_bye -> close [label="error"];

  hangup_unsecure -> shutdown [label="duplex"];
  hangup_unsecure -> close_one;

  shutdown -> wait_for_eof;
  shutdown -> close [label="error"];

  wait_for_eof -> close_one;
  close_one -> wait_for_eof [label="readable"];

  close -> close_both;
  close -> close_one [label="duplex"];

  close_both -> end;
  close_one -> end;
}
