I am looking for an echo server example using libev or libevent that accepts websocket connections: a websocket client connects, sends a message and receives it back. SSL websockets should also be supported. Is there such thing available? If not, what's the most minimal websocket C library that can be plugged into a libev or libevent echo examples?
Related
Is it possible to use SSL_connect() and related API of OpenSSL, for "http" connections ALSO? My program reads the hostname from the command prompt in linux terminal as argument to command, and I don't want to write two different codes switching between "http" and "https" for fetching web-pages..... So just using SSL connection API functions, is there a way to connect to a web server on port 80 without encryption? For the sake of reusing same code simply.
I was looking to create a http2 streaming client in C which is able to connect to server, create stream and keep listening for messages from server on that stream without cancelling the stream unless explicitly cancelled or network issue.
I was trying to implement it via libcurl but seems there is no such support in libcurl, at best what I can do is just make a request with curl and not have a timeout. Then curl will just sit there waiting for the transfer to start or complete, until the server does that. And when one transfer is done, the client can just issue another request and go back to waiting...
But I just want to maintain the stream rather than issuing another request to server after receiving message.
I don't want to use GRPC which provides similar functionality but along with it comes lots of complexity of libs and platform dependencies to be resolved.
Is there any other C based library or any http2 stream reference which I should have a look at?
I am using a openssl library to implement tls server.
How to configure the Heartbeat request timeout and retry count using openssl API to control the keepalive message flow?
I'm assuming you really do mean TLS as you said and not DTLS. Using heartbeats in TLS is quite unusual, although OpenSSL does support it in version 1.0.2. That support is removed from OpenSSL 1.1.0 so, for that reason, I would advise against using it in a new application. Use TCP keep alives instead.
The Heartbeat API is really quite simple. You can do three things:
1) Send a heartbeat using SSL_heartbeat()
2) Find out if a previously sent heartbeat is still pending a response using SSL_get_tlsext_heartbeat_pending()
and
3) Set the Heartbeat mode to disallow the peer from sending heartbeat requests using SSL_set_tlsext_heartbeat_no_requests()
Anything else is up to the application. Retries should not be necessary in TLS because it is designed to run over a reliable transport layer. If the connection is alive, it will get there. If it isn't, it won't. The TCP layer will handle retransmission of lost packets. Timeouts should also really be done at the TCP layer. If the TCP connection times out the SSL connection will fail.
I am trying to design a Client Server kind of application in which my Server is a daemon that accepts client requests, send client's data over a serial channel to the other side(which is an MCU and its firmware will reply to the Server request over the same serial channel). My client can be a CLI application or any other system program.
My idea of design is -
Use message queues for communication between Client and Server since this is a local application and message queues are bidirectional and fast.
Implement a LIBRARY that acts as an interface between multiple clients and the server. This basically does the stuff of packetizing client data into a message(own defined protocol), create message queues, connect to server, send/receive data and then pass it to the respective client(using call backs). This library also exposes API that can be used by clients. Thus this library gives me the flexibility to add support for any new clients keeping the server program unchanged.
Server gets the data over serial from other side and passes it to the library over message queue. The library uses callbacks to send data to the client.
EDIT:
I am thinking of creating Message queues on the fly when any client requests arrive. If I do this, how does the Server daemon(which has already started at linux boot up) gets information about this message queue? Does the message queue has a name that is persistent across and used by other programs? I want to implement clients that will be blocked until it gets response from the server.
Could you guys please review this design and tell me whether my approach is correct. Please reply if you have any other recommendations.
Thanks in advance.
I want to implement proxy support (SOCKS5 and HTTP CONNECT method) in my application. There are two parts that needs to be implemented:
Detection of proxy details (protocol, host, port): I am using libproxy for that.
Connecting to the the proxy server and telling it to relay the packets. Get the connected socket and then use it in your application.
Is there library for the #2 part?
You might be able to hack libmicrohttpd into doing what you want without too much effort, at least as far as the user end. I'm not aware of anything that does what you want straight out of the box.
Now there is proxysocket (https://github.com/brechtsanders/proxysocket/) to do exactly that.
Supports SOCKS4, SOCKS5 and HTTP CONNECT.
The result is a normal connected socket so you don't have to rewrite the rest of your application.
libcurl can receive webpage via proxy. You can send raw http header to it, and let it talk to the proxy