file send in a byte array
ivan fernandez calvo
ivan.fernandez at sacnet.es
Fri May 30 03:12:46 PDT 2008
I try to send a file by DBus into a byte array, the file is complete
send but the java par of aplication been stoped in a function unix
socket java library UInputStream.native_recv and never exit of it.
I try an GArray null termitated and no null terminated and the result is
the same, I try to lie and modified the longitude of array to less then
it is but not work.
the signature of service is:
<method name="getFile">
<arg type="ay" name="ayFile" direction="out" />
</method>
and the implementation is:
gboolean messageDBus_get_file(MessageDBusServidor* obj, GArray**
OUT_ayFile, GError** error) {
*OUT_ayFile = g_array_new (TRUE,TRUE,sizeof(gchar));
/*
i try this too
*OUT_ayFile = g_array_new (FALSE,FALSE,sizeof(gchar));
*/
FILE *fp = NULL;
gchar pBuffer[8192]={0};
gint nByteCount=0;
gint i=0;
gchar sFile[256] = {0};
strcpy(sFile,getenv("HOME"));
strcat(sFile,"/file.txt");
fp = fopen(sFile,"r");
if (fp!=NULL) {
while (!feof(fp)) {
nByteCount = fread(&pBuffer,1,sizeof(pBuffer),fp);
for (i=0;i<nByteCount;i++) {
g_array_append_val(*OUT_ayFile,pBuffer[i]);
}
}
fclose(fp);
}
return TRUE;
}
the java part is
try {
con = DBusConnection.getConnection(DBusConnection.SESSION);
cli = con.getRemoteObject(sInterface,sNode);
List<Byte> bytesFile = cli.getFile();
} catch (DBusException De) {
De.printStackTrace();
}
the file is correct and can work with it but the service never receive
more connections. If i run D-feed the interfaces of service were
disapeared.
Any ideas?
Thx
best regars
--
Un Saludo
Ivan Fernandez Calvo
More information about the dbus
mailing list