how can i transplant the Android layer of RIL code to Linux platform?

633 views Asked by At

I have already complied the layer of RIL code successfully on linux platform and it has run already. The RIL just like the server, it Communicates with client through socket. Now i have written a client. The client can binded the server successfully,but when the client wrote the data into the RIL server,it was wrong. the RIL server crashed. i guess the client's data format is not right and the server cannot analyze the data . How can I organize the client's data format when send the data from socket to server?

by the way, i didn't change the RIL code, especially the function [processCommandsCallback]. I deleted the BINDER in Parcell.cpp and keep the others.

the client's demon code is here:

#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#define UNIX_DOMAIN "/tmp/msg_server_addr"
#define RIL_REQUEST_ANSWER 40
struct parcel 
{
int requestID;
int token;
char data[10];  
};

int main(void)
{ 

 int connect_fd;
 struct sockaddr_un srv_addr;
 p.requestID = RIL_REQUEST_ANSWER;
 p.token= 1;
 strcpy(p.data,"");
 if( (connect_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) 
 {
     perror("client create socket failed");
     return 1;
 }

 srv_addr.sun_family = AF_UNIX;
 strcpy(srv_addr.sun_path, UNIX_DOMAIN);  

  ret = connect(connect_fd, (struct sockaddr*)&srv_addr, sizeof(srv_addr));        
  write(connect_fd, (void *)&p, sizeof(p));
  close(connect_fd);
}
0

There are 0 answers