상세 컨텐츠

본문 제목

원격장비 PORT 열려있는지 확인

C#

by 탑~! 2012. 1. 4. 10:03

본문

 private TcpClient cpTcpClient;

public delegate void ReceiveDataWrite(int port, bool state);

public void WriteData(int port, bool msg)
{
ReceiveDataWrite deleWrite = new ReceiveDataWrite(WriteReceiveData);

this.Invoke(deleWrite, new object[] { port,msg });
}

public void WriteReceiveData(int port, bool msg)
{
RecvtextBox.AppendText(port.ToString() + " " + msg.ToString() + "\r\n");
}

private void ClientReceive(string ip, int port )
{
try
{
cpTcpClient = new TcpClient(ip, port);
if (true == cpTcpClient.Connected)
{
WriteData(port ,true);
}
}
catch (Exception)
{
WriteData(port ,false);
}
finally
{

if (null != cpTcpClient)
cpTcpClient.Close();
}
return;
}


'C#' 카테고리의 다른 글

URL spy  (0) 2012.01.27
IE 실행 시키기  (0) 2012.01.27
IP Address Calculations with C# (Subnetmasks, Networks, …)  (0) 2011.12.26
TreeNode 찾기  (0) 2011.12.14
c# InputBox  (0) 2011.12.14

관련글 더보기