Ok, i've been tyring to get this to work for days, and I got it down to this, but it still all doesnt work. Any advice as to what I may be doing wrong would be greatly appreciated.

Function Listen(ByVal backlog As Integer)
        lsocket.Listen(backlog)
        If Not lsocket.Connected Then
            Console.WriteLine("Winsock error: " + Convert.ToString(System.Runtime.InteropServices.Marshal.GetLastWin32Error()))
        End If
    End Function
    Public Sub tmrlisten_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrlisten.Tick
        txtchatwindow.Text = txtchatwindow.Text + vbNewLine + "Listening..."
        If lsocket.Connected Then
            tmrlisten.Enabled = False
        End If
    End Sub
    Public Sub btnListen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnListen.Click
        Dim endpoint As New IPEndPoint(IPAddress.Any, 0)
        Try
            lsocket.Bind(endpoint)
        Catch ex As Exception
            Console.WriteLine("Winsock error: " + ex.ToString)
        End Try
        Listen(10)
        tmrlisten.Enabled = True
    End Sub

You r tring to write a GUI programming but using Console output .

Please change the Console.**** to something else in GUI

Hi,

Are you trying to setup a server socket on port 0 ?

Loren Soth

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.