Billing Overview
Pay-as-You-Go (postpaid)
Purchasing Channels
Payment Overdue
Refund Instructions
new socket.Conn method, you can create a Socket instance. The parameters of this method include the protocol name (tcp or udp), service address, and service port. new Conn(): Conn
Parameter | Type | Description |
network | string | The protocol name used to establish the connection (tcp or udp). |
host | string | The IP address of the service. |
port | number | The port of the service. |
import socket from "pts/socket";import util from 'pts/util';import {sleep} from 'pts';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.1User-Agent: pts-engine\\r\\n`;tcp_socket.send(util.toArrayBuffer(send_data));const bytes_read = tcp_socket.recv(512);tcp_socket.close();console.log(bytes_read);sleep(1);}
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback