[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Nonblocking Behaviour for .NET
[Thread Prev] | [Thread Next]
- Subject: Re: Nonblocking Behaviour for .NET
- From: Jason Curl <jason@xxxxxxxxxxxxxxxxxxxxxxxx>
- Reply-to: <libssh@xxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Fri, 26 May 2017 17:43:29 +0200
- To: <libssh@xxxxxxxxxx>
On 26/05/2017 12:31, Jason Curl wrote:
Hello,I've been reading the APIs and I don't find a solution, nor an example on how to do nonblocking connect, read and write. I'm writing a wrapper for libssh in .NET using C#, so I can't use any API that talks about an fd_set (requires C macros), struct timeval (which changes per OS). It should work on Windows and Linux.Till now, the only docs I can see is that connect needs to be called more than once. I don't find a way to know when connect is finished (must I really poll? and if so, is there an example somewhere?) I was originally going to write a C-wrapper DLL that handles select() and fd's, but then that won't work on Windows.Or would it, if I use the WinSock2 functionality under windows, and standard Posix under Linux?
It doesn't appear to work (at least yet) ssh_set_blocking(session, false); ssh_connect(session); fd = ssh_get_fd(session);// Here is where i have a wrapper library to do select(), with the fd returned above in the fd_set for writefds.
FD_SET writefds; FD_ZERO(&writefds); FD_SET(fd, &writefds); sres = select(fd+1, NULL, &writefds, NULL, &timeout); // returns 1if (FD_ISSET(fd, &writefds)) rc = ssh_connect(session) // returns -2, indicating EAGAIN.
I don't understand the code too well, but there's only one instance of SSH_AGAIN and that is:
if(!ssh_is_blocking(session) &&!ssh_connect_termination(session)){ returnSSH_AGAIN; }Is there a way to know the connect is finished, or do I have to continuously poll with connect?
Thanks in advance, Jason.
Re: Nonblocking Behaviour for .NET | Aris Adamantiadis <aris@xxxxxxxxxxxx> |
Nonblocking Behaviour for .NET | Jason Curl <jason@xxxxxxxxxxxxxxxxxxxxxxxx> |