MCPcopy Create free account
hub / github.com/Effect-TS/effect / rawNetClient

Function rawNetClient

packages/platform/node-shared/benchmark/Socket.ts:149–166  ·  view source on GitHub ↗
(port: number)

Source from the content-addressed store, hash-verified

147}
148
149const rawNetClient = async (port: number): Promise<RawClient> => {
150 const conn = Net.createConnection({ host: "127.0.0.1", port })
151 await once(conn, "connect")
152 conn.setNoDelay(true)
153 const counter = makeReadCounter()
154 conn.on("data", (chunk: Buffer) => counter.push(chunk.length))
155 return {
156 write(frames) {
157 conn.cork()
158 let flushed = true
159 for (const frame of frames) flushed = conn.write(frame)
160 conn.uncork()
161 return flushed ? Promise.resolve() : once(conn, "drain").then(() => {})
162 },
163 read: counter.read,
164 close: () => conn.destroy()
165 }
166}
167
168const rawWebSocketClient = async (url: string): Promise<RawClient> => {
169 const ws = new WebSocket(url)

Callers 1

Socket.tsFile · 0.85

Calls 5

makeReadCounterFunction · 0.85
onMethod · 0.65
pushMethod · 0.65
onceFunction · 0.50
destroyMethod · 0.45

Tested by

no test coverage detected