MCPcopy Create free account
hub / github.com/SIPp/sipp / reconnect

Method reconnect

src/socket.cpp:1578–1630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1576
1577
1578int SIPpSocket::reconnect()
1579{
1580 if ((!ss_invalid) &&
1581 (ss_fd != -1)) {
1582 WARNING("When reconnecting socket, already have file descriptor %d", ss_fd);
1583 abort();
1584 }
1585
1586 ss_fd = socket_fd(ss_ipv6, ss_transport);
1587 if (ss_fd == -1) {
1588 ERROR_NO("Could not obtain new socket: ");
1589 }
1590
1591 if (ss_invalid) {
1592#if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
1593 ss_ssl = nullptr;
1594
1595 if (transport == T_TLS) {
1596 if ((ss_bio = BIO_new_socket(ss_fd, BIO_NOCLOSE)) == nullptr) {
1597 ERROR("Unable to create BIO object:Problem with BIO_new_socket()");
1598 }
1599
1600 if (!(ss_ssl = SSL_new_client())) {
1601 ERROR("Unable to create SSL object : Problem with SSL_new()");
1602 }
1603
1604 SSL_set_bio(ss_ssl, ss_bio, ss_bio);
1605 }
1606#endif
1607
1608 /* Store this socket in the tables. */
1609 ss_pollidx = pollnfds++;
1610 sockets[ss_pollidx] = this;
1611#ifdef HAVE_EPOLL
1612 epollfiles[ss_pollidx].data.u32 = ss_pollidx;
1613 epollfiles[ss_pollidx].events = EPOLLIN;
1614#else
1615 pollfiles[ss_pollidx].fd = ss_fd;
1616 pollfiles[ss_pollidx].events = POLLIN | POLLERR;
1617 pollfiles[ss_pollidx].revents = 0;
1618#endif
1619
1620 ss_invalid = false;
1621 }
1622
1623#ifdef HAVE_EPOLL
1624 int rc = epoll_ctl(epollfd, EPOLL_CTL_ADD, ss_fd, &epollfiles[ss_pollidx]);
1625 if (rc == -1) {
1626 ERROR_NO("Failed to add FD to epoll");
1627 }
1628#endif
1629 return connect();
1630}
1631
1632#ifdef SO_BINDTODEVICE
1633int SIPpSocket::bind_to_device(const char* device_name) {

Callers 1

executeActionMethod · 0.80

Calls 5

WARNINGFunction · 0.85
socket_fdFunction · 0.85
ERROR_NOFunction · 0.85
ERRORFunction · 0.85
SSL_new_clientFunction · 0.85

Tested by

no test coverage detected