Using VB.Net to establish a network connection Im having a slight problem!
All I want to do is catch a timeout error. As soon as my server notices that the connection cannot be established for a certain amout of time I want to put out a MsgBox. Ive already tried to solve it with a Timer, but it wont work out.
Maybe someone has an Idea:
Public Function Verbindung()
Const portNumber As Integer = 8000
Dim tcpListener As New TcpListener(portNumber)
tcpListener.Start()
Try
** Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
Dim networkStream As NetworkStream = tcpClient.GetStream()
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim clientdata As String = Encoding.ASCII.GetString(bytes)
**Thats where I get the Problem. TcpClient doesnt answer and the whole thing gets stuck!
HELP!!!!
(I need the darn thing for work!)
All I want to do is catch a timeout error. As soon as my server notices that the connection cannot be established for a certain amout of time I want to put out a MsgBox. Ive already tried to solve it with a Timer, but it wont work out.
Maybe someone has an Idea:
Public Function Verbindung()
Const portNumber As Integer = 8000
Dim tcpListener As New TcpListener(portNumber)
tcpListener.Start()
Try
** Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
Dim networkStream As NetworkStream = tcpClient.GetStream()
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim clientdata As String = Encoding.ASCII.GetString(bytes)
**Thats where I get the Problem. TcpClient doesnt answer and the whole thing gets stuck!
HELP!!!!
(I need the darn thing for work!)