This little snippet is useful as a helper function to quickly determine port connectivity between…