[lib][minip] optimize the net_timer to only run if there's a pending event

-add TIME_WAIT socket timeouts
-fix retransmit timeouts to work properly for the right states
-handle a few more socket states in tcp_close()