For the record: I managed to read my socket data by using Gio.DataInputStream [1]. This is rather a workaround, as it avoids passing a void pointer, but it should suit most needs...
[1] http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gio.DataInputStream.html Dnia 5 sierpnia 2012 17:54 "Jasper St. Pierre" <jstpie...@mecheye.net> napisał(a): > On Sun, Aug 5, 2012 at 11:53 AM, gdfc <g...@o2.pl> wrote: > > Thanks for your quick reply! > > What do you mean by "(out caller-allocates) (array length=length)"? What > > would be the correct args for read() be? > > There's nothing you can do right now. You're stuck. I'm sorry. > > > Dnia 5 sierpnia 2012 17:17 "Jasper St. Pierre" <jstpie...@mecheye.net> > > napisał(a): > > > >> Hm, it seems the method is improperly annotated. It should be (out > >> caller-allocates) (array length=length). > >> > >> On Sun, Aug 5, 2012 at 7:55 AM, gdfc <g...@o2.pl> wrote: > >> > Hello! > >> > > >> > I'm currently writing an extension for Gnome Shell using gjs and have to > >> > read some gpsd data from a socket. I've gotten this far: > >> > > >> > const Gio = imports.gi.Gio; > >> > let sockCl = new Gio.SocketClient(); > >> > let sockCon = sockCl.connect_to_host("localhost:2947", null, > >> > null); > >> > let outStr = sockCon.get_output_stream(); > >> > outStr.write('?WATCH={"enable":true,"json":true};', null); > >> > let inStr = sockCon.get_input_stream(); > >> > let b = new Array(128); > >> > inStr.read(b, 1, null); > >> > > >> > However, the read method always fails with the following error: > >> > > >> > Error: Argument 'buffer' (type void) may not be null > >> > > >> > I've tried all read* methods described in the only more or less current > >> > gjs > >> > API reference I've found [1], but they all seem to have the same problem. > >> > This is regardless of what type b is -- it can be an array, a string, a > >> > number or even a function, but it doesn't get recognised as anything > >> > other > >> > than null. I'm aware of [2] (this is the only web search result I've > >> > stumbled upon), but it is of little help. > >> > > >> > So my question here: does anyone know a way to read from a socket in gjs? > >> > It doesn't have to be Gio, any standard lib would do... I've tried some > >> > Soup and GLib methods, but they don't seem to work either. In Gio, I do > >> > at > >> > least get the OutputStream to write reliably... > >> > > >> > Any advice is highly appreciated. Thank you! > >> > > >> > BR > >> > > >> > gdfc > >> > > >> > [1] http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gio.InputStream.html > >> > [2] > >> > https://mail.gnome.org/archives/javascript-list/2012-January/msg00003.html > >> > _______________________________________________ > >> > gnome-shell-list mailing list > >> > gnome-shell-list@gnome.org > >> > https://mail.gnome.org/mailman/listinfo/gnome-shell-list > >> > >> > >> > >> > > > > _______________________________________________ gnome-shell-list mailing list gnome-shell-list@gnome.org https://mail.gnome.org/mailman/listinfo/gnome-shell-list