On Saturday, 9 May 2015 at 23:32:49 UTC, Adam D. Ruppe wrote:
On Saturday, 9 May 2015 at 13:00:01 UTC, wobbles wrote:
On Linux, I'm able to edit a file descriptor after I've created it to tell it to read/write asynchronously, I cant seem to find anything similar on windows however.

Asynchronous I/O on Windows is called "Overlapped I/O". It is a bit involved to use though, especially since D by default doesn't come with all the necessary headers. You can download the win32 api bindings or you can just declare the bits as needed.

My terminal emulator uses overlapped I/O and a spawned process (and on Linux, it uses forkpty!) to talk to ssh on Windows.

https://github.com/adamdruppe/terminal-emulator/blob/master/terminalemulator.d

I had to write a function to make an async pipe, then spawn a process using them, then get and send data. I also declared all the needed functions myself.

A lot of code to go through but it is a working example... a few things to look for are MyCreatePipeEx, CreateProcess, the word 'overlapped', ReadFileEx, and the simpledisplay.d library it imports also uses SleepEx which lets other things trigger.

Thanks adam, this is very helpful!

Reply via email to