recv(size: number): ArrayBuffer
Parameter | Type | Description |
size | number | The limit on the maximum number of bytes that can be received. |
Type | Description |
ArrayBuffer | Received binary data. |
import socket from "pts/socket";import util from 'pts/util';export default function () {const tcp_socket = new socket.Conn('tcp', '127.0.0.1', 80);const send_data = `GET /get HTTP/1.1Host: 127.0.0.1\n`;tcp_socket.send(util.toArrayBuffer(send_data));tcp_socket.recv(512);tcp_socket.close();}