Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

net.d.ts 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. declare module 'net' {
  2. import * as stream from 'stream';
  3. import EventEmitter = require('events');
  4. import * as dns from 'dns';
  5. type LookupFunction = (
  6. hostname: string,
  7. options: dns.LookupOneOptions,
  8. callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
  9. ) => void;
  10. interface AddressInfo {
  11. address: string;
  12. family: string;
  13. port: number;
  14. }
  15. interface SocketConstructorOpts {
  16. fd?: number;
  17. allowHalfOpen?: boolean;
  18. readable?: boolean;
  19. writable?: boolean;
  20. }
  21. interface OnReadOpts {
  22. buffer: Uint8Array | (() => Uint8Array);
  23. /**
  24. * This function is called for every chunk of incoming data.
  25. * Two arguments are passed to it: the number of bytes written to buffer and a reference to buffer.
  26. * Return false from this function to implicitly pause() the socket.
  27. */
  28. callback(bytesWritten: number, buf: Uint8Array): boolean;
  29. }
  30. interface ConnectOpts {
  31. /**
  32. * If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
  33. * Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will
  34. * still be emitted as normal and methods like pause() and resume() will also behave as expected.
  35. */
  36. onread?: OnReadOpts;
  37. }
  38. interface TcpSocketConnectOpts extends ConnectOpts {
  39. port: number;
  40. host?: string;
  41. localAddress?: string;
  42. localPort?: number;
  43. hints?: number;
  44. family?: number;
  45. lookup?: LookupFunction;
  46. }
  47. interface IpcSocketConnectOpts extends ConnectOpts {
  48. path: string;
  49. }
  50. type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
  51. class Socket extends stream.Duplex {
  52. constructor(options?: SocketConstructorOpts);
  53. // Extended base methods
  54. write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
  55. write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean;
  56. connect(options: SocketConnectOpts, connectionListener?: () => void): this;
  57. connect(port: number, host: string, connectionListener?: () => void): this;
  58. connect(port: number, connectionListener?: () => void): this;
  59. connect(path: string, connectionListener?: () => void): this;
  60. setEncoding(encoding?: BufferEncoding): this;
  61. pause(): this;
  62. resume(): this;
  63. setTimeout(timeout: number, callback?: () => void): this;
  64. setNoDelay(noDelay?: boolean): this;
  65. setKeepAlive(enable?: boolean, initialDelay?: number): this;
  66. address(): AddressInfo | {};
  67. unref(): this;
  68. ref(): this;
  69. /** @deprecated since v14.6.0 - Use `writableLength` instead. */
  70. readonly bufferSize: number;
  71. readonly bytesRead: number;
  72. readonly bytesWritten: number;
  73. readonly connecting: boolean;
  74. readonly destroyed: boolean;
  75. readonly localAddress: string;
  76. readonly localPort: number;
  77. readonly remoteAddress?: string;
  78. readonly remoteFamily?: string;
  79. readonly remotePort?: number;
  80. // Extended base methods
  81. end(cb?: () => void): void;
  82. end(buffer: Uint8Array | string, cb?: () => void): void;
  83. end(str: Uint8Array | string, encoding?: BufferEncoding, cb?: () => void): void;
  84. /**
  85. * events.EventEmitter
  86. * 1. close
  87. * 2. connect
  88. * 3. data
  89. * 4. drain
  90. * 5. end
  91. * 6. error
  92. * 7. lookup
  93. * 8. timeout
  94. */
  95. addListener(event: string, listener: (...args: any[]) => void): this;
  96. addListener(event: "close", listener: (had_error: boolean) => void): this;
  97. addListener(event: "connect", listener: () => void): this;
  98. addListener(event: "data", listener: (data: Buffer) => void): this;
  99. addListener(event: "drain", listener: () => void): this;
  100. addListener(event: "end", listener: () => void): this;
  101. addListener(event: "error", listener: (err: Error) => void): this;
  102. addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
  103. addListener(event: "timeout", listener: () => void): this;
  104. emit(event: string | symbol, ...args: any[]): boolean;
  105. emit(event: "close", had_error: boolean): boolean;
  106. emit(event: "connect"): boolean;
  107. emit(event: "data", data: Buffer): boolean;
  108. emit(event: "drain"): boolean;
  109. emit(event: "end"): boolean;
  110. emit(event: "error", err: Error): boolean;
  111. emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean;
  112. emit(event: "timeout"): boolean;
  113. on(event: string, listener: (...args: any[]) => void): this;
  114. on(event: "close", listener: (had_error: boolean) => void): this;
  115. on(event: "connect", listener: () => void): this;
  116. on(event: "data", listener: (data: Buffer) => void): this;
  117. on(event: "drain", listener: () => void): this;
  118. on(event: "end", listener: () => void): this;
  119. on(event: "error", listener: (err: Error) => void): this;
  120. on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
  121. on(event: "timeout", listener: () => void): this;
  122. once(event: string, listener: (...args: any[]) => void): this;
  123. once(event: "close", listener: (had_error: boolean) => void): this;
  124. once(event: "connect", listener: () => void): this;
  125. once(event: "data", listener: (data: Buffer) => void): this;
  126. once(event: "drain", listener: () => void): this;
  127. once(event: "end", listener: () => void): this;
  128. once(event: "error", listener: (err: Error) => void): this;
  129. once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
  130. once(event: "timeout", listener: () => void): this;
  131. prependListener(event: string, listener: (...args: any[]) => void): this;
  132. prependListener(event: "close", listener: (had_error: boolean) => void): this;
  133. prependListener(event: "connect", listener: () => void): this;
  134. prependListener(event: "data", listener: (data: Buffer) => void): this;
  135. prependListener(event: "drain", listener: () => void): this;
  136. prependListener(event: "end", listener: () => void): this;
  137. prependListener(event: "error", listener: (err: Error) => void): this;
  138. prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
  139. prependListener(event: "timeout", listener: () => void): this;
  140. prependOnceListener(event: string, listener: (...args: any[]) => void): this;
  141. prependOnceListener(event: "close", listener: (had_error: boolean) => void): this;
  142. prependOnceListener(event: "connect", listener: () => void): this;
  143. prependOnceListener(event: "data", listener: (data: Buffer) => void): this;
  144. prependOnceListener(event: "drain", listener: () => void): this;
  145. prependOnceListener(event: "end", listener: () => void): this;
  146. prependOnceListener(event: "error", listener: (err: Error) => void): this;
  147. prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
  148. prependOnceListener(event: "timeout", listener: () => void): this;
  149. }
  150. interface ListenOptions {
  151. port?: number;
  152. host?: string;
  153. backlog?: number;
  154. path?: string;
  155. exclusive?: boolean;
  156. readableAll?: boolean;
  157. writableAll?: boolean;
  158. /**
  159. * @default false
  160. */
  161. ipv6Only?: boolean;
  162. }
  163. interface ServerOpts {
  164. /**
  165. * Indicates whether half-opened TCP connections are allowed.
  166. * @default false
  167. */
  168. allowHalfOpen?: boolean;
  169. /**
  170. * Indicates whether the socket should be paused on incoming connections.
  171. * @default false
  172. */
  173. pauseOnConnect?: boolean;
  174. }
  175. // https://github.com/nodejs/node/blob/master/lib/net.js
  176. class Server extends EventEmitter {
  177. constructor(connectionListener?: (socket: Socket) => void);
  178. constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void);
  179. listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
  180. listen(port?: number, hostname?: string, listeningListener?: () => void): this;
  181. listen(port?: number, backlog?: number, listeningListener?: () => void): this;
  182. listen(port?: number, listeningListener?: () => void): this;
  183. listen(path: string, backlog?: number, listeningListener?: () => void): this;
  184. listen(path: string, listeningListener?: () => void): this;
  185. listen(options: ListenOptions, listeningListener?: () => void): this;
  186. listen(handle: any, backlog?: number, listeningListener?: () => void): this;
  187. listen(handle: any, listeningListener?: () => void): this;
  188. close(callback?: (err?: Error) => void): this;
  189. address(): AddressInfo | string | null;
  190. getConnections(cb: (error: Error | null, count: number) => void): void;
  191. ref(): this;
  192. unref(): this;
  193. maxConnections: number;
  194. connections: number;
  195. listening: boolean;
  196. /**
  197. * events.EventEmitter
  198. * 1. close
  199. * 2. connection
  200. * 3. error
  201. * 4. listening
  202. */
  203. addListener(event: string, listener: (...args: any[]) => void): this;
  204. addListener(event: "close", listener: () => void): this;
  205. addListener(event: "connection", listener: (socket: Socket) => void): this;
  206. addListener(event: "error", listener: (err: Error) => void): this;
  207. addListener(event: "listening", listener: () => void): this;
  208. emit(event: string | symbol, ...args: any[]): boolean;
  209. emit(event: "close"): boolean;
  210. emit(event: "connection", socket: Socket): boolean;
  211. emit(event: "error", err: Error): boolean;
  212. emit(event: "listening"): boolean;
  213. on(event: string, listener: (...args: any[]) => void): this;
  214. on(event: "close", listener: () => void): this;
  215. on(event: "connection", listener: (socket: Socket) => void): this;
  216. on(event: "error", listener: (err: Error) => void): this;
  217. on(event: "listening", listener: () => void): this;
  218. once(event: string, listener: (...args: any[]) => void): this;
  219. once(event: "close", listener: () => void): this;
  220. once(event: "connection", listener: (socket: Socket) => void): this;
  221. once(event: "error", listener: (err: Error) => void): this;
  222. once(event: "listening", listener: () => void): this;
  223. prependListener(event: string, listener: (...args: any[]) => void): this;
  224. prependListener(event: "close", listener: () => void): this;
  225. prependListener(event: "connection", listener: (socket: Socket) => void): this;
  226. prependListener(event: "error", listener: (err: Error) => void): this;
  227. prependListener(event: "listening", listener: () => void): this;
  228. prependOnceListener(event: string, listener: (...args: any[]) => void): this;
  229. prependOnceListener(event: "close", listener: () => void): this;
  230. prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
  231. prependOnceListener(event: "error", listener: (err: Error) => void): this;
  232. prependOnceListener(event: "listening", listener: () => void): this;
  233. }
  234. interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
  235. timeout?: number;
  236. }
  237. interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
  238. timeout?: number;
  239. }
  240. type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
  241. function createServer(connectionListener?: (socket: Socket) => void): Server;
  242. function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server;
  243. function connect(options: NetConnectOpts, connectionListener?: () => void): Socket;
  244. function connect(port: number, host?: string, connectionListener?: () => void): Socket;
  245. function connect(path: string, connectionListener?: () => void): Socket;
  246. function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
  247. function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
  248. function createConnection(path: string, connectionListener?: () => void): Socket;
  249. function isIP(input: string): number;
  250. function isIPv4(input: string): boolean;
  251. function isIPv6(input: string): boolean;
  252. }