[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Support external recv and send callbacks


You realize if you are going to modify the cmake stuff to conditionally insert a #define into my callback typedefs there is no reason you can’t do it to the others if you just disable it by default. 
Here is my patch. I am going to submit it on the bug tracker but if you want to use it before they apply it be my guest. 

Attachment: externalio.zip
Description: Zip archive



On May 30, 2017, at 3:25 PM, Jason Curl <jason@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Seeing that cmake is being used, its not too hard. When I compile on mingw64, the WIN32 micro is already set. Not om Cygwin, bit that's not a typical use case. By not too hard I mean about 1 hoir implementation, mostly reading. I can support if you want

 

Sent from my Windows 10 phone

 

From: Joseph Southwell
Sent: Tuesday 30 May 2017 21:16
To: libssh@xxxxxxxxxx
Subject: Re: Support external recv and send callbacks

 

So, according to
http://mono-list.ximian.narkive.com/lfOw5Ldl/mono-net-delegate-incompatibility
MONO and .NET have different requirements on windows (one requires cdecl callbacks and the other requires stdcall). If that is still the case there isn’t really right answer without adding build options and that gets a little out of the area I am being paid to put effort into. 

> On May 28, 2017, at 3:19 PM, Jason Curl <jason@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 
> 
> On 25/05/2017 16:25, Joseph Southwell wrote:
>> I found a flaw in this and will be resubmitting it.
> If you're going to make callbacks public, any way to prefix them with __stdcall? That would allow .NET to use the callbacks also [1], [2], with the only solution I've seen in [3] that is not practical.
> 
> It would mean having to add something like WINAPI to the header file for the typedefs and if we're compiling on Windows then set it to __stdcall (note for 64-bit this is ignored anyway and everything is __fastcall).
> 
> e.g.
> #if defined(WIN32)
> #define WINAPI __stdcall
> #else
> #define WINAPI
> #endif
> 
> Note, you can't do that for the existing APIs, because that would cause breakage.
> 
> I haven't tested on Linux with Mono/dotnet, but I assume here one doesnt need to worry.
>> 
>>> On May 25, 2017, at 9:44 AM, Joseph Southwell <jsouthwell@xxxxxxxxxxxxx> wrote:
>>> 
>>> This patch allows you to replace the calls to send and recv with alternate callbacks. I am using this because I am running an event driven network stack with stackfull coroutines in c++. This makes the whole thing appear blocking to libssh while still sharing threads efficiently. Socket closure is non blocking so I did not add a callback for that but if somebody wanted to extend this to work with something that isn’t really sockets they would need to add a close callback as well since ssh_disconnect calls close on the socket fd.
>>> <0001-got-external-io-working-in-libssh-client.patch>
>> 
> [1] https://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx
> [2] https://msdn.microsoft.com/en-us/library/ektebyzx.aspx
> [3] https://www.codeproject.com/Articles/12512/Using-the-CDECL-calling-convention-in-C-changing
> 


Follow-Ups:
Re: Support external recv and send callbacksAris Adamantiadis <aris@xxxxxxxxxxxx>
References:
Support external recv and send callbacksJoseph Southwell <jsouthwell@xxxxxxxxxxxxx>
Re: Support external recv and send callbacksJoseph Southwell <jsouthwell@xxxxxxxxxxxxx>
Re: Support external recv and send callbacksJason Curl <jason@xxxxxxxxxxxxxxxxxxxxxxxx>
Re: Support external recv and send callbacksJoseph Southwell <jsouthwell@xxxxxxxxxxxxx>
RE: Support external recv and send callbacksJason Curl <jason@xxxxxxxxxxxxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org