FR 8240 then FR 9602 at Madrid
Porto → Madrid → Rome
Timetable, Madrid time
16:30FR 8240 from Porto at the gate
06:00FR 9602 to Rome leaves the gate
13 h 30 apart on the timetable, overnight
FR 9602 leaves 13 h 30 after FR 8240 arrives on the timetable: more than half a day, so not a connection we count.