Fixed port and socket not used even if set

Thanks to Nam Trung for reporting