I've used libwebsockets to develop a server that enable to use a simple linux terminal through a web page. Now i need to edit my code so that the server accept multiple clients. I didn't really understood how this library manage the structs to store client information so that I'm able to recognize each client request.
This is what i've got so far for single client:
int port = 8000;
const char *interface = NULL;
struct lws_context *context;
int opts = 0;
struct lws_context_creation_info info;
memset(&info, 0, sizeof info);
info.port = port;
info.iface = interface;
info.protocols = protocols;
info.ssl_cert_filepath = NULL;
info.ssl_private_key_filepath = NULL;
info.gid = -1;
info.uid = -1;
info.options = opts;
context = lws_create_context(&info);
if (context == NULL) {
fprintf(stderr, "lws init failed\n");
return -1;
}
printf("starting server...\n");
buffer = malloc(sizeof(char) * LSH_RL_BUFSIZE);
outbuf = malloc(sizeof(char) * OUT_BUFFER_SIZE);
strcpy(outbuf,"Welcome to websocket terminal\n");
while (1) {
lws_service(context, 50);
}
lws_context_destroy(context);
return 0;
Can someone give me a good advice or some material to study (official API are too complicated)
Thanks in advance