Developing a lightweight, hi-performance and dynamic JSON api server with C Shaikh Sonny Aman  for  SQABD LT4
Background
Play Tools PHP Java Python C
WHY!!
Requirement http://myserver.com:8080 ? mod =score& action =get_score& id =123 { score:4, id:123 }
The Server if (  (client_socket=accept(server_socket, (struct sockaddr *)&cad, &alen)) < 0) { printf(&quot;accept failed\n&quot;); exit (1); } pthread_create(&tid, NULL, serverthread, (void*)client_socket ); While(1){ } accept connection from client run a thread to process
Processing Request Read all available data recv(client_socket, buffer,buffer_size, 0);
Processing Request Host:  www.http.header.free.fr Accept: image/gif, image/x-xbitmap, image/jpeg, imagepjpeg, Accept-Language: Fr Accept - Encoding: gzip, deflate Get the request params mod =score& action =get_score& id =123 GET: Http1.1
Calling Dynamic Function PIC : Position Independent Code dlopen(PATH, mode) dlsym(handle, fun_name) void  (*fn)( int * cs,cJSON** js); void   echo_name ( int * client_socket, cJSON** request)
Demo
QnA

Aman: Developing a lightweight, hi-performance and dynamic JSON api server with C

  • 1.
    Developing a lightweight,hi-performance and dynamic JSON api server with C Shaikh Sonny Aman for SQABD LT4
  • 2.
  • 3.
    Play Tools PHPJava Python C
  • 4.
  • 5.
    Requirement http://myserver.com:8080 ?mod =score& action =get_score& id =123 { score:4, id:123 }
  • 6.
    The Server if( (client_socket=accept(server_socket, (struct sockaddr *)&cad, &alen)) < 0) { printf(&quot;accept failed\n&quot;); exit (1); } pthread_create(&tid, NULL, serverthread, (void*)client_socket ); While(1){ } accept connection from client run a thread to process
  • 7.
    Processing Request Readall available data recv(client_socket, buffer,buffer_size, 0);
  • 8.
    Processing Request Host: www.http.header.free.fr Accept: image/gif, image/x-xbitmap, image/jpeg, imagepjpeg, Accept-Language: Fr Accept - Encoding: gzip, deflate Get the request params mod =score& action =get_score& id =123 GET: Http1.1
  • 9.
    Calling Dynamic FunctionPIC : Position Independent Code dlopen(PATH, mode) dlsym(handle, fun_name) void (*fn)( int * cs,cJSON** js); void echo_name ( int * client_socket, cJSON** request)
  • 10.
  • 11.