I think you need to wait for the telnet server to respond. With no real error checking, this should show the login prompt.
void setup() {
Ethernet.begin(mac, ip);
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");
if (client.connect(server, 23)) {
Serial.println("connected");
// wait for a response. This should also check client.connected() and a timeout.
while(client.available() == 0) delay(1);
// get the response
while (client.available() > 0) {
char c = client.read();
Serial.print(c);
}
}
else {
Serial.println("connection failed");
}
}