Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Net.Sockets;
- namespace TestDaLuong
- {
- class Server
- {
- public string IP { get; set; }
- public int Port { get; set; }
- }
- class Program
- {
- static void Main()
- {
- Console.Write("Nhap IP hoac website can kiem tra: ");
- String strWeb = Console.ReadLine();
- Thread[] arrTh = new Thread[640];
- for (int i = 0; i < arrTh.Length; i++)
- {
- arrTh[i] = new Thread(Print);
- }
- for (int i = 0; i < arrTh.Length; i++)
- {
- arrTh[i].Start(new Server() { IP = strWeb, Port = i * 100 });
- }
- Console.ReadKey();
- }
- static void Print(object obj)
- {
- Server st = (Server)obj;
- TcpClient client;
- for (int iPort = st.Port; iPort < st.Port + 100; iPort++)
- {
- client = new TcpClient();
- try
- {
- client.Connect(st.IP, iPort);
- Console.Write(st.Port.ToString() + "\t");
- }
- catch (Exception exc)
- {
- //MessageBox.Show(ex.Message);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment