Public Class clsHostPort
Private m_hostname As String
Private m_port As Integer
Private m_timeout As Integer
Private m_bIsOpen As Boolean
Sub New(ByVal HostName As String, ByVal Port As Integer, Optional ByVal timeout As Integer = 10)
'127.0.0.1 is the local machine
m_hostname = HostName
m_port = Port
m_timeout = timeout
m_bIsOpen = False
End Sub
Public Function IsPortOpen() As Boolean
'first check valid port value
If m_port >= 0 And m_port < 65536 Then
Else
Return False
End If
Dim Client As System.Net.Sockets.TcpClient = Nothing
Try
Client = New System.Net.Sockets.TcpClient(m_hostname, m_port)
Client.ReceiveTimeout = m_timeout
m_bIsOpen = True
Catch ex As System.Net.Sockets.SocketException
Console.WriteLine(ex.Message)
m_bIsOpen = False
Finally
If Not Client Is Nothing Then
Client.Close()
End If
IsPortOpen = m_bIsOpen
End Try
End Function
End Class
Suscribirse a:
Enviar comentarios (Atom)
VBA Access. Redondeo de números decimales con el método medio redondeo. Alternativa a la función Round (bankers round)
Private Function Redondeo(ByVal Numero As Variant, ByVal Decimales As Integer) As Double 'Aplica método medio redondeo (half round ...
-
Option Compare Database Option Explicit '***************************** ' 'Ejemplo de uso ' 'selecciona 1 ficher...
-
Option Compare Database Option Explicit 'Zip / UnZip file or folder 'http://www.codekabinett.com/rdumps.php?Lang=2&targetDoc...
No hay comentarios:
Publicar un comentario