Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Net.Sockets;
- namespace KiemTraPort
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- /// <summary>
- /// Kiem tra port nao mo tu 1 den 1024
- /// </summary>
- private void btCheck_Click(object sender, EventArgs e)
- {
- tbPort.Text = "Please wait...";
- TcpClient client = new TcpClient();
- int iPort;
- String strListPost = "";
- for (iPort = 1; iPort <= 1024; iPort++)
- {
- client = new TcpClient();
- try
- {
- client.Connect(tbIP.Text, iPort);
- strListPost += iPort.ToString() + " ";
- //tbPort.Text = strListPost;
- }
- catch (Exception ex)
- {
- //MessageBox.Show(ex.Message);
- }
- }
- tbPort.Text = strListPost;
- MessageBox.Show("Check finish!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment