forked from JacobFischer/netlinkwrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
72 lines (64 loc) · 2.11 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* A simple synchronous TCP module wrapping the netlink library for simple
* IO.
*/
declare class NetLinkWrapper {
/**
* Constructs a netlinkwrapper, taking no arguments
* NOTE: It is not connected to anything after creations. Use `connect`
* for that.
*/
constructor();
/**
* A synchronous version of net.Socket.connect(port[, host]).
* Note: it does not accept a connectListener as part of the argument
*
* @param port - The port to connect to.
* @param host - The host to connect to, defaults to `127.0.0.1`.
*/
connect(port: number, host?: string): void;
/**
* Sets if the socket is blocking or not.
*
* @param blocking - Required. True to set to block, false to disable
* blocking.
*/
blocking(blocking: boolean): void;
/**
* Gets if the socket is currently set to block or not.
*
* @returns True if set to block. False if not blocking.
*/
blocking(): boolean;
/**
* Sets or gets if the socket is blocking. When passed a boolean sets
* if blocking. When omitted gets if blocking.
*
* @param blocking - If passed then acts as a setter boolean,
* if not passed then acts a getter.
* @returns If using as a setter, returns undefined. If using as a
* getter gets if the socket is blocking.
*/
blocking(blocking?: boolean): boolean | void;
/**
* Reads a socket for data. Basically a replacement for on('data');
*
* @param {number} buffer - How many bytes to read from the buffer.
* @param {boolean} [blocking] - If passed sets the blocking mode,
* the same as if you called `blocking()` prior to calling `read()`.
* @returns The string read from the socket,
* or undefined if no data to read.
*/
read(buffer: number, blocking?: boolean): string | undefined;
/**
* Writes data to the socket.
*
* @param {string} data - The data to write to the socket.
*/
write(data: string): void;
/**
* Disconnects/Destroys the connection.
*/
disconnect(): void;
}
export = NetLinkWrapper;