# Enable/Disable socks

This sample application demonstrates how to enable/disable socks.

1.Implement initialization callback and get the DataFactory instance

Optionally, initialization callback can be provided with get manager instance.
Data factory will call callback when manager initialization is complete.

auto initCb = [&](telux::common::ServiceStatus status) {
       std::lock_guard<std::mutex> lock(mtx);
       status_ = status;
       initCv.notify_all();
    };
    
    auto &dataFactory = telux::data::DataFactory::getInstance();
    Copy to clipboard

2. Get the SocksManager instances

std::unique_lock<std::mutex> lck(mtx);
    auto dataSocksMgr  = dataFactory.getSocksManager(opType, initCb);
    Copy to clipboard

3. Wait for DataConnectionManager initialization to be complete

initCv.wait(lck);
    Copy to clipboard

3.1 Check SocksManager initialization state

If SocksManager initialization failed, new initialization attempt can be accomplished
by calling step 2. If SocksManager initialization succeed, proceed to step 4.

if (status_ == telux::common::ServiceStatus::SERVICE_AVAILABLE) {
       // Go to step 4
    }
    else {
       //Go to step 2 for another initialization attempt
    }
    Copy to clipboard

4. Optionally, instantiate enable Socks callback instance

auto respCb = [](telux::common::ErrorCode error) {
       std::cout << std::endl << std::endl;
       std::cout << "CALLBACK: "
                   << "enableSocks Response"
                   << (error == telux::common::ErrorCode::SUCCESS ? " is successful" : " failed")
                   << ". ErrorCode: " << static_cast<int>(error) << "\n";
       promise.set_value(1);
    };
    Copy to clipboard

5. Enable/Disable socks using enableSocks()

dataSocksMgr->enableSocks(enable, respCb);
    Copy to clipboard

Now, response callback will be called for the setFirewall response.

Last Published: May 20, 2026

[Previous Topic
Enable L2TP and add a tunnel](https://docs.qualcomm.com/bundle/publicresource/80-PF458-7/topics/enable_and_add_tunnel_l2tp.md) [Next Topic
Get dedicated radio bearer status and indication](https://docs.qualcomm.com/bundle/publicresource/80-PF458-7/topics/get_drb_status_and_indication.md)