For example, my group have three member: A, B, C, and different links via different NIC/ISP.
Suddenly the network of A is broken and A disconnected, after a while, the network of A back to normal.
At this time, I want to reconnect A and add A into my group.
(I use group broadcast mode and nonblocking mode)
Ok, let me explain a general rule.
A socket can be connected only once. When connected, it can only be disconnected, or it can be explicitly closed.
A group can be connected multiple times. Every time you connect, this adds a new link to the existing member connections. For that you can use either srt_connect or srt_connect_group, just the latter allows you to pass some extra member-related settings.
Follow the example of the srt-test-live application in the file located at testing/testmedia.cpp function SrtCommon::UpdateGroupStatus. This function is being called after every reading and writing activity.
Note that the group doesn't reconnect by itself. When it breaks, it breaks, you need to recognize this situation, likely by extracting this information from the SRT_MSGCTRL object passed to the reading or writing function, or separately by calling srt_group_data. OTOH note that every connection is always new to the group. To identify which connection is which the best way is to set explicitly the "token" value.
So I can add a newly connected link into a existing group?
Exactly. The group remains connected as long as at least one link is alive.
Note also that the blocking rules are kinda different for the groups. The connect call normally blocks until the socket is connected. If you do the first group connection, when you use srt_connect_group, this function exits upon connection of the first link (in non-blocking mode, only at this time does the group get epoll +W). When the group is connected, adding a new connection happens always in background and returns immediately - the new link will simply appear among the existing members at some point.
On the listener side only the first connection causes that srt_accept may return a connection. When the group is already connected, the connection is handled in the background, although the listener generates an edge-only event SRT_EPOLL_UPDATE. As previously, you will see the new member reported in the group data report.
work like a charm, thx!