Invalid socket, not initialized
If there's a better place for questions like this, please direct me there.
I'm a recent developer with gjs and, encouraged by tests using it with Gtk with Glade, I'm currently trying to add networking but having trouble with a simple UDP socket. I've made a minimal problem case to demonstrate the issue:
#!/usr/bin/env gjs
const { Gio } = imports.gi;
var socket = new Gio.Socket({ "family":Gio.SocketFamily.IPV4, "type":Gio.SocketType.DATAGRAM, "protocol":Gio.SocketProtocol.UDP});
var sa = Gio.InetSocketAddress.new_from_string('192.168.8.128', 48995);
socket.bind(sa, true);
When I run this I always see:
(gjs:103363): Gjs-CRITICAL **: 11:16:24.990: JS ERROR: Gio.IOErrorEnum: Invalid socket, not initialized
@./utest.js:5:
(gjs:103363): Gjs-CRITICAL **: 11:16:24.990: Script ./utest.js threw an exception
Should the code snippet work? It's not obvious from the Gio.Socket documentation how to initialize the socket (or even that it needs to be initialized).
Any insights or help would be appreciated.
chris