When trying to use a Gio.Socket, I see this error. Simplified code to demonstrate the issue is:
#!/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);
The problem is in socket.bind() - commenting it out removes the error.
The full error is:
chris@d8:~/src/devicefinder-gjs$ ./utest.js
(gjs:113277): Gjs-CRITICAL **: 19:13:42.766: JS ERROR: Gio.IOErrorEnum: Invalid socket, not initialized
@./utest.js:5:8
(gjs:113277): Gjs-CRITICAL **: 19:13:42.766: Script ./utest.js threw an exception
Could someone point out the obvious mistake please?
Thanks,
chris