17 Matching Annotations
- Nov 2023
- May 2023
-
blog.cloudflare.com blog.cloudflare.com
-
🥳
```js import { connect } from 'cloudflare:sockets';
export default { async fetch(req: Request) { const gopherAddr = "gopher.floodgap.com:70"; const url = new URL(req.url);
try { const socket = connect(gopherAddr); const writer = socket.writable.getWriter() const encoder = new TextEncoder(); const encoded = encoder.encode(url.pathname + "\r\n"); await writer.write(encoded); return new Response(socket.readable, { headers: { "Content-Type": "text/plain" } }); } catch (error) { return new Response("Socket connection failed: " + error, { status: 500 }); }
} };
ts connect(address: SocketAddress | string, options?: SocketOptions): Socket
declare interface Socket { get readable(): ReadableStream; get writable(): WritableStream; get closed(): Promise<void>; close(): Promise<void>; startTls(): Socket; }
declare interface SocketOptions { secureTransport?: string; allowHalfOpen: boolean; }
declare interface SocketAddress { hostname: string; port: number; } ```
-
- Mar 2023
-
blog.cloudflare.com blog.cloudflare.com
Tags
Annotators
URL
-
- Dec 2022
-
blogs.univ-poitiers.fr blogs.univ-poitiers.fr
Tags
Annotators
URL
-
-
datatracker.ietf.org datatracker.ietf.org
-
ganganichamika.medium.com ganganichamika.medium.com
-
ganganichamika.medium.com ganganichamika.medium.com
-
www.form3.tech www.form3.tech
-
developers.cloudflare.com developers.cloudflare.com
Tags
Annotators
URL
-
-
developers.cloudflare.com developers.cloudflare.com
-
www.cloudflare.com www.cloudflare.com
-
blog.cloudflare.com blog.cloudflare.com
Tags
Annotators
URL
-
-
blog.cloudflare.com blog.cloudflare.com