How do I programm a C++ project with client and server communicating via libwebsocket.

The problem is,

context = libwebsocket_create_context(port, interface, protocols, libwebsocket_internal_extensions, cert_path, key_path, "", -1, -1, opts);
if (!context)
{
fprintf(stderr, "libwebsocket init failed\n");
return;
}

returns NULL, if the server has already opened a context with the same port.

What am I doing wrong?