I am using glibmm v2.42 on linux.
I want to create a client / server using native linux socket.
When trying to create a socket, an exception is always thrown with code 15 (not supported).
On the code below I looped over socket family enum, type enum and protocol enum but it always fails.
#include <iostream>
#include <glibmm.h>
#include <giomm.h>
int main(){
Glib::init();
Gio::init();
std::vector<Gio::SocketFamily> fams = {Gio::SOCKET_FAMILY_UNIX , Gio::SOCKET_FAMILY_IPV4 , Gio::SOCKET_FAMILY_IPV6};
std::vector<Gio::SocketType> types = {Gio::SOCKET_TYPE_STREAM, Gio::SOCKET_TYPE_DATAGRAM, Gio::SOCKET_TYPE_SEQPACKET };
std::vector<Gio::SocketProtocol> protocols = {Gio::SOCKET_PROTOCOL_DEFAULT , Gio::SOCKET_PROTOCOL_TCP, Gio::SOCKET_PROTOCOL_UDP, Gio::SOCKET_PROTOCOL_SCTP };
Glib::RefPtr<Gio::Cancellable> cancellable = Gio::Cancellable::create();
for(int i = 0; i < fams.size(); i++){
for(int j = 0; j < types.size(); j++){
for(int k= 0; k < protocols.size(); k++){
Gio::SocketFamily fam = fams[i];
Gio::SocketType type= types[j];
Gio::SocketProtocol protocol = protocols[k];
try {
Glib::RefPtr<Gio::Socket> socket = Gio::Socket::create(fam , type, protocol , cancellable);
} catch(const Gio::Error& e){
std::cout << e.code() << std::endl;
}
}
}
}
return 0;
}
Any ideas ? Does anyone have a working example of client/server with native linux socket using glibmm ?
Thanks for your help.
EDIT : In the code I removed the XXX and wrote the loops. This code returns 15 for all parameters configurations