router vs switch difference code example Example: router vs switch switch connect hosts, router connects switches to networks beyond