interface INetworkManager {
// Methods
${createTcpSession}(ipAddress: string, port: number): ${ITcpSession};
${createUdpSession}(): ${IUdpSession};
${createTcpListener}(host: string, port: number): Promise<${ITcpListener}>;
${getSessions}(type: ${Network.SessionType}): ${INetworkSession}[];
}
// This interface is not available in managed environment
// This interface is not available in native environment
createTcpSession(ipAddress: string, port: number): ${ITcpSession};
// This method is not available in managed environment
// This method is not available in native environment
ipAddress
port
Returns the reference to created session object.
Creates new TCP session.
Create new TCP session:
var session = networkManager.createTcpSession("192.168.33.50", 502);
createUdpSession(): ${IUdpSession};
// This method is not available in managed environment
// This method is not available in native environment
Returns the reference to created session object.
Creates new UDP session.
Create new UDP session:
var session = networkManager.createUdpSession();
createTcpListener(host: string, port: number): Promise<${ITcpListener}>;
// This method is not available in managed environment
// This method is not available in native environment
host
port
Returns a promise that yields a reference to the prepared listener object.
Creates new TCP listener object.
Listen for a new TCP connection
async function listen() {
var l = await networkManager.createTcpListener("localhost", 80);
var socket = await l.listen();
}
getSessions(type: ${Network.SessionType}): ${INetworkSession}[];
// This method is not available in managed environment
// This method is not available in native environment
type
Array of requested session objects.
Retrieve the array of TCP or UDP (or both) session objects.
Obtain a list of TCP sessions.
var tcpSessions = networkManager.getSessions(Network.SessionType.Tcp);