Peers connect by exchanging Capability Exchange Request/Answer. Before this can happen, they have to set up a TCP (or SCTP) connection. One peer initiates the connection and the other 'accepts' it. First peer then sends CER (has information about its own identity and the applications supported by it). Responder sends back CEA (identity, set of common applications - or may be full list of its applications). But if the responder sees that they don't have any application in common, it sends CEA with a diameter error.
Peers are equal, so either side may initiate the connection. But in implementations, generally servers don't initiate the connections, they accept/reject.
Either side may disconnect sending Disconnect Peer Request (DPR). Other side responds with DPA.
There are finer details like simultaneous CER handling, error cases, vendor and security information in CER and rejection of DPR under some conditions.