'client application using nw_connection_receive works great with wired network
But cannot receive any data using wifi (tls connection), while client using BSD socket doesn't have this issue, my tcp and tls config:
auto config_tcp = ^(nw_protocol_options_t tcp_op) {
nw_tcp_options_set_connection_timeout(tcp_op, connection_timeout); //set timeout to 5 seconds
nw_tcp_options_set_enable_keepalive(tcp_op, true); //keep_live
nw_tcp_options_set_no_delay(tcp_op, true); //enable no delay
nw_tcp_options_set_enable_fast_open(tcp_op, false);
};
auto config_tls = ^(nw_protocol_options_t tls_options) {
auto sec_options = nw_tls_copy_sec_protocol_options(tls_options);
sec_protocol_options_set_min_tls_protocol_version(sec_options, tls_protocol_version_TLSv12);
sec_protocol_options_set_max_tls_protocol_version(sec_options, tls_protocol_version_TLSv12);
sec_protocol_options_append_tls_ciphersuite_group(sec_options, tls_ciphersuite_group_default);
sec_protocol_options_set_peer_authentication_required(sec_options, false);
nw_release(sec_options);
};
Code for receiving
static void handleIncomingVideo( void* caller, nw_connection_t conn = nullptr )
{
auto pCaller = reinterpret_cast< NetworkTalk* >( caller );
if ( conn == nullptr )
{
conn = pCaller->getConnection( Video );
if ( conn == nullptr )
{
return;
}
}
nw_connection_receive(
conn,
1, std::numeric_limits<uint32_t>::max(),
^( dispatch_data_t content,
nw_content_context_t context,
bool is_complete,
nw_error_t receive_error )
{
int dSize = (content == nullptr) ? 0 : (int)dispatch_data_get_size(content);
syslog(LOG_INFO, "NT(%s)L:%d nw_connection_receive : video data! content:len=%d", __FUNCTION__, __LINE__, dSize);
....
}
when disconnect, the above client log shows received nullptr
Any idea?*, do I need special configure for wifi? BTW, it is mesh wifi.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
