Hi All,<br>I am using dbus glib binding. I have a code where i am trying to transfer a 5 MB file over dbus. I am getting an error which is <br><br>"Failed to write file 'copy-client.JK5K5T': fwrite() failed: Bad address"<br><br>However for small file ( about 10-20 k), I am not getting the same problem. I looked up the dbus specs and that says that the max message size is 2 pow 27. I am not able to understand the reason of failure. I am attaching my code for your reference.<br><br>--------------- server-code------------<br>/* some-object.h */<br>#ifndef __SOME_OBJECT_H__<br>#define __SOME_OBJECT_H__<br><br>#include &lt;glib-object.h&gt;<br><br>typedef struct _SomeObject SomeObject;<br>struct _SomeObject<br>{<br>&nbsp;&nbsp;&nbsp; GObject&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; parent_obj;<br>&nbsp;&nbsp;&nbsp; gint &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; m_a;<br>&nbsp;&nbsp;&nbsp; gchar*&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; m_b;<br>&nbsp;&nbsp;&nbsp; gfloat&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; m_c;<br>};<br><br>typedef struct _SomeObjectClass SomeObjectClass;<br>struct _SomeObjectClass<br>{<br>&nbsp;&nbsp;&nbsp; GObjectClass&nbsp;&nbsp;&nbsp; parent_class;<br><br>&nbsp;&nbsp;&nbsp; /* Some useful methods may follow. */<br>&nbsp;&nbsp;&nbsp; gboolean&nbsp;&nbsp;&nbsp; (*method1)&nbsp;&nbsp;&nbsp; (SomeObject *self, gint x,gchar **y,gint *z,GError **error);<br>&nbsp;&nbsp;&nbsp; void&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (*method2)&nbsp;&nbsp;&nbsp; (SomeObject *self, gchar*);<br>};<br><br>GType&nbsp;&nbsp;&nbsp; some_object_get_type ();<br><br>gboolean some_object_method1 (SomeObject *self, gint x,gchar**y,gint *z,GError **);&nbsp;&nbsp;&nbsp; /* virtual */<br>void&nbsp;&nbsp;&nbsp; some_object_method2 (SomeObject *self, gchar*);&nbsp;&nbsp;&nbsp; /* virtual */<br>void&nbsp;&nbsp;&nbsp; some_object_method3 (SomeObject *self, gfloat);&nbsp;&nbsp;&nbsp; /* non-virtual */<br><br><br>/* Handy macros */<br>#define SOME_OBJECT_TYPE&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; (some_object_get_type ())<br>#define SOME_OBJECT(obj)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOME_OBJECT_TYPE, SomeObject))<br>#define SOME_OBJECT_CLASS(c)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (G_TYPE_CHECK_CLASS_CAST ((c), SOME_OBJECT_TYPE, SomeObjectClass))<br>#define SOME_IS_OBJECT(obj)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (G_TYPE_CHECK_TYPE ((obj), SOME_OBJECT_TYPE))<br>#define SOME_IS_OBJECT_CLASS(c)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (G_TYPE_CHECK_CLASS_TYPE ((c), SOME_OBJECT_TYPE))<br>#define SOME_OBJECT_GET_CLASS(obj)&nbsp;&nbsp;&nbsp; (G_TYPE_INSTANCE_GET_CLASS ((obj), SOME_OBJECT_TYPE, SomeObjectClass))<br><br>#endif<br><br><br><br>/* some-object.c */<br><br>#include "some-object.h"<br>#include "some-object-glue.h"<br>#include &lt;dbus/dbus-glib-bindings.h&gt;<br>#include &lt;string.h&gt;<br>#include &lt;sys/stat.h&gt;<br><br>static GObjectClass *parent_class = ((void *)0);<br>static void some_object_init
 (SomeObject *self);<br><br>char *FILENAME = NULL;<br><br>gboolean some_object_method1_impl (SomeObject *self, gint a, gchar **y,gint *z,GError **error)<br>{<br>&nbsp;&nbsp;&nbsp; struct stat stat_buf;<br>&nbsp;&nbsp;&nbsp; self-&gt;m_a = a;<br>&nbsp;&nbsp;&nbsp; g_print ("Method1: %i\n", self-&gt;m_a);<br>/*&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; *y = (char *)g_malloc0(6);<br>&nbsp;&nbsp;&nbsp; strcpy(*y,"sumit");<br>*/&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; stat(FILENAME,&amp;stat_buf);<br>&nbsp;&nbsp;&nbsp; *y = g_malloc(stat_buf.st_size + 100);<br>&nbsp;&nbsp;&nbsp; if(g_file_get_contents(FILENAME,y,z,error))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_print("Contents read\n");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(g_file_set_contents("copy-server",*y,*z,NULL))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_print("Contents written\n");<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;
 else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_print("Contents reading failed... %s \n",(*error)-&gt;message);<br><br>&nbsp;&nbsp;&nbsp; return TRUE;<br>}<br><br>void some_object_method2_impl (SomeObject *self, gchar* b)<br>{<br>&nbsp;&nbsp;&nbsp; self-&gt;m_b = b;<br>&nbsp;&nbsp;&nbsp; g_print ("Method2: %s\n", self-&gt;m_b);<br>}<br><br><br>/* Public methods. */<br>gboolean some_object_method1 (SomeObject *self, gint a,gchar **y,gint *z,GError **error)<br>{<br>&nbsp;&nbsp;&nbsp; return SOME_OBJECT_GET_CLASS (self)-&gt;method1 (self, a,y,z,error);<br>}<br><br>void&nbsp;&nbsp;&nbsp; some_object_method2 (SomeObject *self, gchar* b)<br>{<br>&nbsp;&nbsp;&nbsp; SOME_OBJECT_GET_CLASS (self)-&gt;method2 (self, b);<br>}<br><br>void&nbsp;&nbsp;&nbsp; some_object_method3 (SomeObject *self, gfloat c)<br>{<br>&nbsp;&nbsp;&nbsp; self-&gt;m_c = c;<br>&nbsp;&nbsp;&nbsp; g_print ("Method3: %f\n", self-&gt;m_c);<br>}<br><br><br>void&nbsp;&nbsp;&nbsp; some_object_dispose (GObject
 *self)<br>{<br>&nbsp;&nbsp;&nbsp; static gboolean first_run = TRUE;<br><br>&nbsp;&nbsp;&nbsp; if (first_run)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; first_run = FALSE;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* Call g_object_unref on any GObjects that we hold, but don't break the object */<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; parent_class-&gt; dispose (self);<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>void&nbsp;&nbsp;&nbsp; some_object_finalize (GObject *self)<br>{<br>&nbsp;&nbsp;&nbsp; parent_class-&gt; finalize (self);<br>}<br><br>/* Here is where we override any functions. Since we have no properties or even fields, none of the below are needed. */<br>void&nbsp;&nbsp;&nbsp; some_object_class_init&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (gpointer g_class, gpointer class_data)<br>{<br>&nbsp;&nbsp;&nbsp; GObjectClass&nbsp;&nbsp;&nbsp; *object_class&nbsp;&nbsp;&nbsp; = G_OBJECT_CLASS
 (g_class);<br>&nbsp;&nbsp;&nbsp; SomeObjectClass&nbsp;&nbsp;&nbsp; *this_class&nbsp;&nbsp;&nbsp; = SOME_OBJECT_CLASS (g_class);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //assign value to parent class<br>&nbsp;&nbsp;&nbsp; parent_class = g_type_class_peek_parent (g_class);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //assing pointer values to the base class members<br>&nbsp;&nbsp;&nbsp; object_class-&gt; dispose = &amp;some_object_dispose;<br>&nbsp;&nbsp;&nbsp; object_class-&gt; finalize = &amp;some_object_finalize;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //assign value to derived class members<br>&nbsp;&nbsp;&nbsp; this_class-&gt;method1 = &amp;some_object_method1_impl;<br>&nbsp;&nbsp;&nbsp; this_class-&gt;method2 = &amp;some_object_method2_impl;<br><br>&nbsp;&nbsp;&nbsp; dbus_g_object_type_install_info(G_TYPE_FROM_CLASS(this_class),&amp;dbus_glib__object_info);<br>}<br><br>void some_object_init (SomeObject *self)<br>{<br>&nbsp;&nbsp;&nbsp; self-&gt;m_a =
 1;<br>&nbsp;&nbsp;&nbsp; self-&gt;m_c = 1.03f;<br>&nbsp;&nbsp;&nbsp; self-&gt;m_b = "sumit";<br>}<br><br>GType some_object_get_type () <br>{<br>&nbsp;&nbsp;&nbsp; static GType g_define_type_id = 0; <br>&nbsp;&nbsp;&nbsp; if ((g_define_type_id == 0)) <br>&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; static const GTypeInfo g_define_type_info = <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sizeof (SomeObjectClass), <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (GBaseInitFunc) ((void *)0), <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (GBaseFinalizeFunc) ((void *)0), <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (GClassInitFunc) some_object_class_init, <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (GClassFinalizeFunc) ((void *)0), <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ((void *)0), <br>&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sizeof (SomeObject), <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0, <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (GInstanceInitFunc) some_object_init, <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }; <br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_define_type_id = g_type_register_static <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; G_TYPE_OBJECT, <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "SomeObject", <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &amp;g_define_type_info, <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (GTypeFlags) 0<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; } <br><br>&nbsp;&nbsp;&nbsp; return g_define_type_id; <br>}<br><br>int main(int argc,char *argv[])<br>{<br>&nbsp;&nbsp;&nbsp; SomeObject *so =
 NULL;<br>&nbsp;&nbsp;&nbsp; DBusGConnection *bus;<br>&nbsp;&nbsp;&nbsp; g_type_init();<br>&nbsp;&nbsp;&nbsp; GMainLoop *mainLoop = NULL;<br>&nbsp;&nbsp;&nbsp; int request_ret;<br>&nbsp;&nbsp;&nbsp; GError *error = NULL;<br><br>&nbsp;&nbsp;&nbsp; DBusGProxy *proxy = NULL;<br>&nbsp;&nbsp;&nbsp; char *x;<br><br>&nbsp;&nbsp;&nbsp; FILENAME = argv[1];<br><br>&nbsp;&nbsp;&nbsp; so = g_object_new(SOME_OBJECT_TYPE,NULL);<br><br>&nbsp;&nbsp;&nbsp; bus = dbus_g_bus_get(DBUS_BUS_SESSION,NULL);<br><br>&nbsp;&nbsp;&nbsp; proxy = dbus_g_proxy_new_for_name(bus,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS);<br><br>&nbsp;&nbsp;&nbsp; dbus_g_connection_register_g_object(bus,"/com/example/SomeObject",G_OBJECT(so));<br><br>&nbsp;&nbsp;&nbsp; if(!org_freedesktop_DBus_request_name(proxy,"com.example.SomeObject",0,&amp;request_ret,&amp;error))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g_print("Unable to register service\n");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 return 1;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; mainLoop = g_main_loop_new(NULL,FALSE);<br>&nbsp;&nbsp;&nbsp; g_main_loop_run(mainLoop);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; return 0;<br>}<br>------------------- End server code --------------<br><br>---------- Client code -------------------<br>#define DBUS_API_SUBJECT_TO_CHANGE<br><br>#include &lt;dbus/dbus.h&gt;<br>#include &lt;dbus/dbus-glib.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;stdio.h&gt;<br>#include "some-object-bindings.h"<br><br>int main (int argc, char **argv)<br>{<br>&nbsp; DBusGConnection *connection;<br>&nbsp; GError *error;<br>&nbsp; DBusGProxy *proxy;<br>&nbsp; gchar *x;<br>&nbsp; gint length;<br>&nbsp; <br>&nbsp; g_type_init ();<br><br>&nbsp; error = NULL;<br>&nbsp; connection = dbus_g_bus_get
 (DBUS_BUS_SESSION,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;error);<br>&nbsp; if (connection == NULL)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_printerr ("Failed to open connection to bus: %s\n",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error-&gt;message);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_error_free (error);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit (1);<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp; proxy = dbus_g_proxy_new_for_name (connection,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 "com.example.SomeObject",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "/com/example/SomeObject",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "com.example.SomeObject");<br><br>&nbsp; error = NULL;<br><br>&nbsp; if(!com_example_SomeObject_method1(proxy,10,&amp;x,&amp;length,&amp;error))<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; printf("Error --- %s\n",error-&gt;message);<br>&nbsp;&nbsp;&nbsp; return 1;<br>&nbsp; }<br><br>&nbsp; printf("File details... length = %d\n",length);<br>&nbsp; error = NULL;<br>&nbsp; if(!g_file_set_contents("copy-client",x,length,&amp;error))<br>&nbsp;&nbsp;&nbsp; &nbsp; printf("Error message =
 %s\n",error-&gt;message);<br>&nbsp; <br>&nbsp; return 0;<br>}<br>------------ End Client&nbsp; code -------------<br><br>--------- Introspection XML ------------<br>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;<br><br>&lt;node name="/com/example/SomeObject"&gt;<br><br>&nbsp; &lt;interface name="com.example.SomeObject"&gt;<br>&nbsp;&nbsp;&nbsp; &lt;annotation name="org.freedesktop.DBus.GLib.CSymbol" value="some_object"/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;method name="Method1"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!-- This is optional, and in this case is redunundant --&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;annotation name="org.freedesktop.DBus.GLib.CSymbol" value="some_object_method1"/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;arg type="u" name="x" direction="in" /&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;arg type="s" name="y" direction="out" /&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;arg type="u" name="z" direction="out" /&gt;<br>&nbsp;&nbsp;&nbsp;
 &lt;/method&gt;<br>&nbsp; &lt;/interface&gt;<br>&lt;/node&gt;<br>--------- End Introspection XML ------------<br><br><br>Please help.<br><br>Regads,<br>Sumit<br><p>&#32;


      <!--5--><hr size=1></hr> Now you can chat without downloading messenger. <a href="http://in.rd.yahoo.com/tagline_webmessenger_5/*http://in.messenger.yahoo.com/webmessengerpromo.php">Click here</a> to know how.