asynctools icon indicating copy to clipboard operation
asynctools copied to clipboard

The AsyncIPC example does not work on windows

Open abijahm opened this issue 5 years ago • 2 comments

i get the following error when running the asyncipc example

example.nim(12)          example
asyncipc.nim(238)        open
oserr.nim(110)           raiseOSError
Error: unhandled exception: The parameter is incorrect.
 [OSError]
Error: execution of an external program failed: 'e:\inter-process\example.exe '

if i add echo getLastError()

after this line it seems to work https://github.com/cheatfate/asynctools/blob/master/asynctools/asyncipc.nim#L233

abijahm avatar Aug 10 '18 17:08 abijahm

@abijahm could you please share your example.nim code?

cheatfate avatar Aug 11 '18 00:08 cheatfate

import asyncdispatch

import asynctools/asyncipc

var inBuffer = newString(64)
var outBuffer = "TEST STRING BUFFER"

# create new IPC object
let ipc = createIpc("test")
# open `read` side channel to IPC object
let readHandle = open("test", sideReader)
# open `write` side channel to IPC object
let writeHandle = open("test", sideWriter)

# writing string to IPC object
waitFor write(writeHandle, cast[pointer](addr outBuffer[0]), len(outBuffer))
# reading data from IPC object
var c = waitFor readInto(readHandle, cast[pointer](addr inBuffer[0]), 64)

inBuffer.setLen(c)
doAssert(inBuffer == outBuffer)

echo inBuffer
# Close `read` side channel
close(readHandle)
# Close `write` side channel
close(writeHandle)
# Close IPC object
close(ipc)

output

example.nim(12)          example
asyncipc.nim(237)        open
oserr.nim(110)           raiseOSError
Error: unhandled exception: The parameter is incorrect.
 [OSError]
Error: execution of an external program failed: 'e:\inter-process\example.exe '

abijahm avatar Aug 11 '18 11:08 abijahm