Hey, all. I'm trying to interface with nimsuggest according to the the [Nim IDE Integration Guide](https://nim-lang.org/docs/nimsuggest.html) and have run into some issues with sockets. I'm trying to connect to nimsuggest over port 6000 but my connection keeps being refused. Any help would be greatly appreciated! import std / [osproc, os, net, strformat, with, paths, exitprocs] const EndToken = "\e" PauseToken = "\e\e" ClearToken = "\e\e\e" Port = Port 6000 var commands: Channel[string] results: Channel[string] commands.open() results.open() proc processTask(task: string) = let socket = newSocket() for i in 0..9: socket.connect("localhost", Port) # Connection refused [OSError] socket.send(&"{task}\c\l") discard "do stuff here..." socket.close() results.send(EndToken) proc suggestThread() {.thread.} = while true: let cmd = commands.recv() case cmd of EndToken: break of PauseToken: os.sleep(300) else: processTask(cmd) var prevProject: string var nimsuggest: Process proc shutdown() {.noconv.} = if nimsuggest.isNil: return nimsuggest.terminate() nimsuggest.close() nimsuggest = nil proc startup(project: string; debug: bool): bool = if nimsuggest.isNil or project != prevProject or not nimsuggest.running: let pathToExe = Path findExe("nimsuggest") assert pathToExe.string.len != 0 prevProject = project shutdown() let nimPath = findExe("nim").splitFile.dir.parentDir var args = if debug: @["--debug"] else: @[] with args: add fmt"--port:{Port}" add "--v2" add project add "--log" add "--debug" nimsuggest = startProcess(pathToExe.string, nimPath, args, options = {poStdErrToStdOut, poInteractive, poDaemon}) # give it some time to startup: commands.send(PauseToken) return nimsuggest != nil var processing: bool proc requestSuggestion(filename, cmd: string; col, currentLine: int) = commands.send &"{cmd} \"{filename}\":{currentLine+1}:{col}\c\l" processing = true var backgroundThread: Thread[void] createThread[void](backgroundThread, suggestThread) proc main() = assert startup("myTestProject.nim", true) addExitProc shutdown while true: requestSuggestion("myTestProject.nim", "con", 5, 10) os.sleep(50) main() Run
on ubuntu: ../.choosenim/toolchains/nim-2.0.0/lib/system.nim(35) suggestThread ../Documents/nimsuggestTest/nimsuggestTest.nim(19) processTask ../.choosenim/toolchains/nim-2.0.0/lib/pure/net.nim(2068) connect ../.choosenim/toolchains/nim-2.0.0/lib/std/oserrors.nim(92) raiseOSError Error: unhandled exception: Connection refused [OSError] Run on windows: ../.choosenim/toolchains/nim-2.0.0/lib/system.nim(35) suggestThread ../Documents/nimsuggestTest/nimsuggestTest.nim(19) processTask ../.choosenim/toolchains/nim-2.0.0/lib/pure/net.nim(2068) connect ../.choosenim/toolchains/nim-2.0.0/lib/std/oserrors.nim(92) raiseOSError Error: unhandled exception: No connection could be made because the target machine actively refused it. [OSError] Run