Opening, closing of port and logging