After a compilation trying of a sockets example code (
https://goo.gl/ddDE8u), some errors gone.. and among them, a the pointer casting related one that I cannot solve by myself.
A function inside called socket_address_to_string() receives an smart pointer of type Glib::RefPtr<Gio::
SocketAddress>... and seems need then to be cast to a pointer of type Glib::RefPtr<Gio::InetSocketAddress>...
How to solve it ?
(Exit of compilation)
---
$ g++ -std=c++14 client.cc -o client $(pkg-config --cflags --libs glibmm-2.4 giomm-2.4)
client.cc: In function ‘Glib::ustring {anonymous}::socket_address_to_string(const Glib::RefPtr<Gio::SocketAddress>&)’:
client.cc:71:77: error: no matching function for call to ‘dynamic_pointer_cast(const Glib::RefPtr<Gio::SocketAddress>&)’
auto isockaddr = std::dynamic_pointer_cast<Gio::InetSocketAddress>(address);
^
In file included from /usr/include/c++/6/bits/shared_ptr.h:52:0,
from /usr/include/c++/6/condition_variable:44,
from client.cc:2:
/usr/include/c++/6/bits/shared_ptr_base.h:1334:5: note: candidate: template<class _Tp, class _Tp1, __gnu_cxx::_Lock_policy _Lp> std::__shared_ptr<_Tp1, _Lp> std::dynamic_pointer_cast(const std::__shared_ptr<_Tp2, _Lp>&)
dynamic_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept
^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:1334:5: note: template argument deduction/substitution failed:
client.cc:71:77: note: ‘const Glib::RefPtr<Gio::SocketAddress>’ is not derived from ‘const std::__shared_ptr<_Tp2, _Lp>’
auto isockaddr = std::dynamic_pointer_cast<Gio::InetSocketAddress>(address);
^
In file included from /usr/include/c++/6/condition_variable:44:0,
from client.cc:2:
/usr/include/c++/6/bits/shared_ptr.h:456:5: note: candidate: template<class _Tp, class _Tp1> std::shared_ptr<_Tp1> std::dynamic_pointer_cast(const std::shared_ptr<_Tp2>&)
dynamic_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept
^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr.h:456:5: note: template argument deduction/substitution failed:
client.cc:71:77: note: ‘const Glib::RefPtr<Gio::SocketAddress>’ is not derived from ‘const std::shared_ptr<_Tp2>’
auto isockaddr = std::dynamic_pointer_cast<Gio::InetSocketAddress>(address);
^
client.cc: In function ‘int main(int, char**)’:
client.cc:148:3: error: ‘Type’ is not a member of ‘Gio::Socket’
Gio::Socket::Type socket_type;
^~~
client.cc:191:3: error: ‘socket_type’ was not declared in this scope
socket_type = use_udp ? Gio::Socket::Type::DATAGRAM : Gio::Socket::Type::STREAM;
^~~~~~~~~~~
client.cc:191:40: error: ‘Gio::Socket::Type’ has not been declared
socket_type = use_udp ? Gio::Socket::Type::DATAGRAM : Gio::Socket::Type::STREAM;
^~~~
client.cc:191:70: error: ‘Gio::Socket::Type’ has not been declared
socket_type = use_udp ? Gio::Socket::Type::DATAGRAM : Gio::Socket::Type::STREAM;
^~~~
client.cc:192:30: error: ‘IPV6’ is not a member of ‘Gio::SocketFamily’
socket_family = use_ipv6 ? Gio::SocketFamily::IPV6 : Gio::SocketFamily::IPV4;
^~~
client.cc:192:56: error: ‘IPV4’ is not a member of ‘Gio::SocketFamily’
socket_family = use_ipv6 ? Gio::SocketFamily::IPV6 : Gio::SocketFamily::IPV4;
^~~
client.cc:196:75: error: ‘Gio::Socket::Protocol’ has not been declared
cket = Gio::Socket::create(socket_family, socket_type, Gio::Socket::Protocol::DEFAULT);
^~~~~~~~
client.cc:275:53: error: ‘OUT’ is not a member of ‘Glib::IOCondition’
ensure_condition(socket, "send", cancellable, Glib::IOCondition::OUT);
^~~~
client.cc:308:54: error: ‘IN’ is not a member of ‘Glib::IOCondition’
ensure_condition(socket, "receive", cancellable, Glib::IOCondition::IN);