Skip to content

Commit

Permalink
Use named pipes on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
saul-jb committed Apr 12, 2024
1 parent 3567ad4 commit 537a2a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/rpc/src/rpc-client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as net from 'net'
import { platform } from 'os'
import Path from 'path'
import * as cborg from 'cborg'
import * as lp from 'it-length-prefixed'
import { pipe } from 'it-pipe'
Expand All @@ -17,6 +19,10 @@ export class RPCClient {
private readonly stream = pushable<JSONRPCRequest>({ objectMode: true })

constructor (path: string) {
if (platform() === 'win32') {
path = Path.join('\\\\.\\pipe', path)
}

this.socket = net.connect({ path })

this.rpc = new JSONRPCClient((request: JSONRPCRequest, options) => {
Expand Down
6 changes: 6 additions & 0 deletions packages/rpc/src/rpc-server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as net from 'net'
import { platform } from 'os'
import Path from 'path'
import * as cborg from 'cborg'
import * as lp from 'it-length-prefixed'
import { pipe } from 'it-pipe'
Expand Down Expand Up @@ -32,6 +34,10 @@ export class RPCServer {
private readonly options: Required<RPCServerOptions>

constructor (path: string, options: RPCServerOptions = {}) {
if (platform() === 'win32') {
path = Path.join('\\\\.\\pipe', path)
}

this.path = path

this.options = {
Expand Down

0 comments on commit 537a2a9

Please sign in to comment.