J
JiumingZhu
Guest
I tried to use .Net to get a available port, but I got error 5729: Incompatible datatypes found during runtime conversion. (5729)
I Don't know where I shoud explicit the expressions
Beneath is my demo code using .Net:
Now I'm trying to use windows api 'GetTcpTable', but I don't know how to prepare the data structure 'PMIB_TCPTABLE'.
Continue reading...
I Don't know where I shoud explicit the expressions
Beneath is my demo code using .Net:
Code:
DEFINE VARIABLE htPorts AS System.Collections.Hashtable.
DEFINE VARIABLE IPProperties AS System.Net.NetworkInformation.IPGlobalProperties.
DEFINE VARIABLE connection AS System.Net.NetworkInformation.TcpConnectionInformation EXTENT.
DEFINE VARIABLE ix AS INTEGER NO-UNDO .
DEFINE VARIABLE iPort AS INTEGER INITIAL 12121 NO-UNDO .
IPProperties = System.Net.NetworkInformation.IPGlobalProperties:GetIPGlobalProperties().
connection = IPProperties:GetActiveTcpConnections().
htPorts = NEW System.Collections.Hashtable().
DO ix = 1 TO EXTENT(connection):
IF NOT htPorts:Contains(connection[ix]:LocalEndPoint:Port) THEN
htPorts:Add(connection[ix]:LocalEndPoint:Port,0).
IF connection[ix]:RemoteEndPoint:Address:ToString() = "127.0.0.1":U THEN DO:
IF NOT htPorts:Contains(connection[ix]:RemoteEndPoint:Port) THEN
htPorts:Add(connection[ix]:RemoteEndPoint:Port, 0).
END.
END.
ix = 0.
DO WHILE ix < 10:
ix = ix + 1.
IF htPorts:Contains(iPort) THEN
DO:
iPort = iPort + 1.
END.
ElSE LEAVE.
END.
MESSAGE iport.
Now I'm trying to use windows api 'GetTcpTable', but I don't know how to prepare the data structure 'PMIB_TCPTABLE'.
Continue reading...