chiarissimo: grazie mille.
azz e io che ero abiutato a fare un semplicissimo function (addr, port) con asp semplice :quote:
una precisazione pero (dovrei riuscire a sistemare da solo cmq)
private bool CheckStatusPort(string Addr, string Port) {
// addr e port non devo dichiararli di nuovo vero? a poi port non dovrebbe essere int?
string Addr = "192.168.0.1";
int Port = 80;
TcpClient Sock = new TcpClient();
try {
Sock.Connect(Addr, Port);
Sock.Close();
return true;
} catch (Exception E) {
return false;
}
Sock = null;
}
Così, richiamando CheckStatusPort riceverai un valore booleano a seconda dell'apertura o meno della porta.
Ecco un esempio di come proseguire:
string dbAddr, dbPort;
DataSet ds = ... // Popolo il dataset
for (int i=0; i < ds.Tables[0].Rows.Count; i++) {
dbAddr = (string) ds.Tables[0].Rows[i]["Addr"];
// idem come sopra: port dovrebbe essere int o sbaglio?
dbPort = (string) ds.Tables[0].Rows[i]["Port"];
if ( CheckStatusPort(dbAdrr, dbPort) )
Response.Write(dbAddr + ": " + dbPort + " - Porta aperta");
else
Response.Write(dbAddr + ": " + dbPort + " - Porta utilizzata");
}