Skip to content
File

Blob: src/cloudflare/internal/sockets.d.ts

typescript37 lines
1// Copyright (c) 2023 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5// Type definitions for c++ implementation.
6 
7import { type ServiceStub } from 'cloudflare-internal:workers';
8 
9export class Socket {
10 readonly readable: unknown;
11 readonly writable: unknown;
12 readonly closed: Promise<void>;
13 close(): Promise<void>;
14 startTls(options: TlsOptions): Socket;
15}
16 
17export type TlsOptions = {
18 expectedServerHostname?: string;
19};
20 
21export type SocketAddress = {
22 hostname: string;
23 port: number;
24};
25 
26export type SocketOptions = {
27 secureTransport?: 'off' | 'on' | 'starttls';
28 allowHalfOpen?: boolean;
29};
30 
31export function connect(
32 address: string | SocketAddress,
33 options?: SocketOptions
34): Socket;
35 
36export function internalNewHttpClient(socket: Socket): Promise<ServiceStub>;