Is there any way to associate callback functions with sockets in Linux?
For example, After connect(s, (struct sockaddr *)peeraddr, sizeof(*peeraddr)) function has connected client with server, is there a way to associate a function- afterRecv with socket- s such that after recv function has read some data from socket, afterRecv gets called?
My socket is of blocking type. The reason behind this kind of requirement is, I am working with a OpenSSL which does many send/recv calls on socket during handshake period internally. If I modify OpenSSL then it would be quite cumbersome to modify each and every recv. So I was thinking if I can add callback that would make my job easy.
The flow should be:
Socket connection logic
Recv function
After recv has read data, afterRecv gets called as a callback on recv
recv()by your own version (wrapping around the originalrecv()) would do the job, wouldn't it? - alk