iosのブーストasioライブラリを使用してdvrを接続しようとしています。このアプリケーションは、ipv4ネットワークのエミュレータで正常に動作します。しかし、私がAppstore上でアプリケーションを提出すると、appleはipv6ネットワーク上で動作しないため、アプリケーションを拒否しました。アップルサイトでは、アプリケーションがipv6ネットワークをサポートする必要があることがわかります。 https://developer.apple.com/news/?id=05042016aIOSブーストasio ipv6ネットワークから接続
この問題は、DVRのIPアドレスがDB(ハードコードされている)から取得されたブーストライブラリを使用してDVRに接続しようとしているセクションにあると思います。コード。
boost::asio::io_service io_service_;
tcp::resolver::iterator endpoint_iter_;
tcp::resolver resolver_; //to healp resolving hostname and ip
stringstream strstream;//create a stringstream
strstream << port;//add number to the stream
endpoint_iter_ = resolver_.resolve(tcp::resolver::query(ip.c_str(),strstream.str()));
start_connect(endpoint_iter_);
// Start the deadline actor. You will note that we're not setting any
// particular deadline here. Instead, the connect and input actors will
// update the deadline prior to each asynchronous operation.
deadline_timer_.async_wait(boost::bind(&dvr_obj::check_deadline, this));
//starting thread for dvr connection
io_service_.reset();
thread_ = new boost::thread(boost::bind(&boost::asio::io_service::run, &io_service_));
start_connect方法
void start_connect(tcp::resolver::iterator endpoint_iter)
{
try
{
if (endpoint_iter != tcp::resolver::iterator())
{
drill_debug_info("trying to connect %s \n",name.c_str());
// Set a deadline for the connect operation.
deadline_timer_.expires_from_now(boost::posix_time::seconds(10));
// Start the asynchronous connect operation.
socket_.async_connect(endpoint_iter->endpoint(),
boost::bind(&dvr_obj::handle_connect,
this, _1, endpoint_iter));
}
else
{
// There are no more endpoints to try. Shut down the client.
connectivity = false;
}
} catch (int e) {
connectivity = false;
}
}
だから私は、IPv6ネットワーク上で動作するように上記のコードに変更する方法が混乱しています。インターネットで解決策を見つけることができませんでした。
' resolver_.resolveを(エントリのリストに反復子を返します。あなたのコードは最初のエントリを使用しています。あなたがリストを反復するならば、あなたはIPv6のエントリを見つけることができます... – kenba
応答のためにありがとう、私はいくつかの参照コードを教えてください。 – CodeDezk