| 655 | } |
| 656 | |
| 657 | void SrtCommon::Init(string host, int port, string path, map<string,string> par, SRT_EPOLL_OPT dir) |
| 658 | { |
| 659 | m_direction = dir; |
| 660 | InitParameters(host, path, par); |
| 661 | |
| 662 | int backlog = 1; |
| 663 | if (m_mode == "listener" && par.count("groupconnect") |
| 664 | && true_names.count(par["groupconnect"])) |
| 665 | { |
| 666 | backlog = 10; |
| 667 | } |
| 668 | |
| 669 | Verb() << "Opening SRT " << DirectionName(dir) << " " << m_mode |
| 670 | << "(" << (m_blocking_mode ? "" : "non-") << "blocking," |
| 671 | << " backlog=" << backlog << ") on " |
| 672 | << host << ":" << port; |
| 673 | |
| 674 | try |
| 675 | { |
| 676 | if (m_mode == "caller") |
| 677 | { |
| 678 | if (m_group_nodes.empty()) |
| 679 | { |
| 680 | OpenClient(host, port); |
| 681 | } |
| 682 | #if ENABLE_BONDING |
| 683 | else |
| 684 | { |
| 685 | OpenGroupClient(); // Source data are in the fields already. |
| 686 | } |
| 687 | #endif |
| 688 | } |
| 689 | else if (m_mode == "listener") |
| 690 | OpenServer(m_adapter, port, backlog); |
| 691 | else if (m_mode == "rendezvous") |
| 692 | OpenRendezvous(m_adapter, host, port); |
| 693 | else |
| 694 | { |
| 695 | throw std::invalid_argument("Invalid 'mode'. Use 'client' or 'server'"); |
| 696 | } |
| 697 | } |
| 698 | catch (...) |
| 699 | { |
| 700 | // This is an in-constructor-called function, so |
| 701 | // when the exception is thrown, the destructor won't |
| 702 | // close the sockets. This intercepts the exception |
| 703 | // to close them. |
| 704 | Verb() << "Open FAILED - closing SRT sockets"; |
| 705 | if (m_bindsock != SRT_INVALID_SOCK) |
| 706 | srt_close(m_bindsock); |
| 707 | if (m_sock != SRT_INVALID_SOCK) |
| 708 | srt_close(m_sock); |
| 709 | m_sock = m_bindsock = SRT_INVALID_SOCK; |
| 710 | throw; |
| 711 | } |
| 712 | |
| 713 | int pbkeylen = 0; |
| 714 | SRT_KM_STATE kmstate, snd_kmstate, rcv_kmstate; |
nothing calls this directly
no test coverage detected