A TCPConnection is a task-owned resource, if you need to use the resource you'll have to do task-messaging which requires some stream utilities (see vibe.stream.*). For this purpose, I think a task pipe would be what you're looking for.

The way you'd use it isn't too far off from what you had in mind, I think it should end up being something like this (untested) solution:

import vibe.d;

shared static this() {
	listenTCP(2500, (conn) {
		auto pipe = new TaskPipe;
		
		runTask({ 
			
			auto remoteconn = connectTCP("localhost", 2525);
		
			pipe.write(remoteconn);
			
		});

		conn.write(pipe);
		
	});
}