Read buffers in GObject bindings



Hi,

I have been trying to write an applet where i need to use UDP (for autodiscovery). Using Gio.Socket works very will up until "receive_from" is called. The call does read from the socket, returns the number of bytes read as well as the source of packet but the
actual buffer content is not available.

Going down the rabbit hole I noticed that function.cpp in GJS/GObject will allocate a new c-array and copy/coerce the content of the JS ByteArray to the c-buffer. When the called function returns 'gjs_invoke_c_function' will not copy back the content from the c-array
into the JS buffer. This makes receive_from (nearly) useless in GJS.

Is this intentional or is there a plan to support low-level calls using read-buffers?

I have made a gist showing what I need: https://gist.github.com/maghul/4ddaa5879ef0ece5dbe3

This doesn't work using the current GJS (nor the current GLib) but I have made
minor fixes which makes it functional which are in the repo-clones
    https://github.com/maghul/gjs/tree/emh/readbuffer
    https://github.com/maghul/glib/tree/emh/socket

Are there other ways of using UDP sockets in GJS which I've missed?

  best regards,
    /Magnus


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]