Set slave ID (if defined) for TCP client

Based on patch by Maarten.