dialog fsock {
  title "Destiny Sockets"
  size -1 -1 114 107
  option dbu
  list 1, 3 8 64 95, sort size
  button "&Get Info", 20, 69 9 37 12
  button "&Close", 21, 69 90 37 12, default ok
  button "Close &Sock", 23, 69 37 37 12
  button "&Refresh", 22, 69 23 37 12
  box "Socket Lists:", 90, 1 0 110 106
}

dialog fsockmin {
  title "Socket Information"
  size 20 200 112 145
  option dbu
  box "Socket Info:", 90, 3 4 106 122
  text "Name:", 1, 6 17 16 8
  text "Port:", 2, 6 51 11 8
  text "IP:", 3, 6 39 7 8
  text "Bytes Sent:", 4, 6 64 27 8
  text "Bytes Rcvd:", 5, 6 76 29 8
  text "Last Sent Data:", 6, 6 101 40 8
  text "Type:", 7, 6 28 14 8
  text "Connection Time:", 8, 6 113 42 8
  text "", 11, 54 17 50 8, right
  text "", 12, 79 29 25 8, right
  text "", 13, 63 40 41 8, right
  text "", 14, 64 65 40 8, right
  text "", 15, 64 77 40 8, right
  text "", 16, 56 89 48 8, right
  text "", 17, 56 101 48 8, right
  text "", 18, 60 113 44 8, right
  button "Close", 20, 71 130 37 12, default ok
  text "Last Rcvd Data:", 9, 6 89 39 8
  text "", 10, 62 68 0 8
  text "", 19, 66 52 38 8, right
  button "Refresh", 21, 3 130 37 12
}

alias fsock if ($dialog(fsock) == $null) { dialog -m fsock fsock }

alias -l fsock.list { var %i = 1 | did -r fsock 1 | while (%i <= $sock(*,0)) { did -a fsock 1 $sock(*,%i) | inc %i  } }

alias -l fsock.inf {
  var %tmp = $1, %tmp2 = fsock.sock. $+ %tmp, %tmp3 = did -a %tmp2
  if ($sock(%tmp)) {
    $iif($dialog(%tmp2),goto x,dialog -m %tmp2 fsockmin) | :x | %tmp3 11 $sock(%tmp).name | %tmp3 12 $sock(%tmp).type | %tmp3 13 $sock(%tmp).ip | %tmp3 14 $sock(%tmp).sent | %tmp3 15 $sock(%tmp).rcvd 
    %tmp3 17 $duration($sock(%tmp).ls) | %tmp3 16 $duration($sock(%tmp).lr) |  %tmp3 18 $duration($sock(%tmp).to) | %tmp3 19 $sock(%tmp).port
  }
}

on *:DIALOG:fsock:init:*: { fsock.list }

on *:DIALOG:fsock:sclick:*: {
  if ($did == 20) { fsock.inf $did(fsock,1).seltext }
  if ($did == 22) { fsock.list }
  if ($did == 23) { if ($did(fsock,1).seltext) { sockclose $did(fsock,1).seltext | fsock.list } }
}

on *:DIALOG:fsock.sock.*:sclick:*: {
  if ($did == 21) { fsock.inf $gettok($dname,3,46) }
}
