I want to send the data in JSON over sockets in a server-client application written in C. I am using json-c / libjson library for handling JSON data in C application. By working on some of the tutorials I am able to create JSON object and able to parse it successfully. Now I want to use the JSON data format for the communication of server-client. Here is part of my server and client code server.c int main () { int listenfd = 0 , connfd = 0 ; //related with the server struct sockaddr_in serv_addr ; //json_object * jobj; uint8_t buf [ 158 ], i ; memset (& buf , '0' , sizeof ( buf )); listenfd = socket ( AF_INET , SOCK_STREAM , 0 ); serv_addr . sin_family = AF_INET ; serv_addr . sin_addr . s_addr = htonl ( INADDR_ANY ); serv_addr . sin_port = htons ( 8888 ); bind ( listenfd , ( struct sockaddr *)& serv_addr , sizeof ( serv_addr )); printf ( "binding\n" ); listen ( listenf...
Comments
Post a Comment