Hello i have been following a tutorial and after finishing the server part wont run. can someone please help me with this error.
Error:
At this line:Code:An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll
Code:Code:Dim server As New clsServer
I will need help with the client part as well.Code:Imports System.Net Imports System.Net.Sockets Public Class clsServer Dim server As New clsServer Private Listener As TcpListener Private t As System.Threading.Thread Private reader As System.IO.StreamReader Public Clients As New Collection Public Sub StartListening() Listener = New TcpListener(IPAddress.Parse("127.0.0.1"), 6580) Listener.Start() t = New System.Threading.Thread(AddressOf ListenContinuously) t.Start() End Sub Public Sub StopListening() t.Abort() End Sub Private Sub ListenContinuously() While True = True If Listener.Pending = True Then AcceptClient() End If 'PollForMessages() <This is for a later tutorial. That's why this line is commented out> End While End Sub Private Sub AcceptClient() Dim pendingClient As TcpClient Dim nameOfClient As String pendingClient = Listener.AcceptTcpClient() reader = New System.IO.StreamReader(pendingClient.GetStream) nameOfClient = reader.ReadLine() Clients.Add(pendingClient, nameOfClient) MessageBox.Show(nameOfClient & " has just signed in.") End Sub Private Sub btnStartServer_Click(sender As System.Object, e As System.EventArgs) Handles btnStartServer.Click server.StartListening() btnStartServer.Enabled = False btnStopServer.Enabled = True End Sub Private Sub btnStopServer_Click(sender As System.Object, e As System.EventArgs) Handles btnStopServer.Click server.StopListening() btnStopServer.Enabled = False btnStartServer.Enabled = True End Sub Private Sub clsServer_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing server.StopListening() End Sub End Class![]()


Reply With Quote
but fixing it is the problem.. since the next tutorial is not up yet i have no idea what to do.
