Added protocol detection mechanisms (fixes #36).