diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2009-11-30 22:35:43 +0100 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2009-11-30 22:35:43 +0100 |
commit | 76d6838223718a5432baddb4fa5b3e82440c9ff2 (patch) | |
tree | 87ab207db64dc0d1772d273ffc5749cfe0820581 /libssh/socket.c | |
parent | 0bfb9d476c3dfc1ed74763665611891bcc277e9e (diff) | |
download | libssh-76d6838223718a5432baddb4fa5b3e82440c9ff2.tar.gz libssh-76d6838223718a5432baddb4fa5b3e82440c9ff2.tar.xz libssh-76d6838223718a5432baddb4fa5b3e82440c9ff2.zip |
Some brain surgery to add event-based sockets
chapter 1- SSH Socket Connections.
I would like to be able to
-Have a ssh_poll_ctx object
-Add a ssh socket over it
-launch the socket connection (using socket functions)
-ssh_poll_ctx_dopoll()
-Wait for the timeout or have the "connected" callback called
Diffstat (limited to 'libssh/socket.c')
-rw-r--r-- | libssh/socket.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libssh/socket.c b/libssh/socket.c index 8acc76ce..a250f2ea 100644 --- a/libssh/socket.c +++ b/libssh/socket.c @@ -181,6 +181,18 @@ void ssh_socket_register_pollcallback(struct socket *s, ssh_poll_handle p){ s->poll=p; } +/** @internal + * @brief returns the poll handle corresponding to the socket, + * creates it if it does not exist. + * @returns allocated and initialized ssh_poll_handle object + */ +ssh_poll_handle ssh_socket_get_poll_handle(struct socket *s){ + if(s->poll) + return s->poll; + s->poll=ssh_poll_new(s->fd,0,ssh_socket_pollcallback,s); + return s->poll; +} + /** \internal * \brief Deletes a socket object */ @@ -191,6 +203,8 @@ void ssh_socket_free(struct socket *s){ ssh_socket_close(s); buffer_free(s->in_buffer); buffer_free(s->out_buffer); + if(s->poll) + ssh_poll_free(s->poll); SAFE_FREE(s); } |