Click here to Skip to main content
15,897,094 members

internal exception in this code

hamzah1 asked:

Open original thread
this code is for client/server application it give me an exception in the client while i run the port between these 2 application i need help to solve this problem
"the 2 application are broadcast media player broadcast media over Lan to Client"
the sever code ;
Iwill type the place of exception in code in client
Imports System.Net.Sockets

Imports System.Threading
Imports System.Windows.Forms
Imports System.IO



Public Class broadcast



    Private thread As Thread
    Private listener As New TcpListener(5234)
    Private writers As New ArrayList
    Private name As String



    Public Sub New(ByVal name As String)
        MyBase.New()
        Me.name = name

    End Sub

    Public Sub start()
        listener.Start()
        thread = New Thread(AddressOf RunServer)
        thread.Start()
    End Sub


    Public Sub RunServer()
        Try
            While True
                Dim writer As New BinaryWriter(New NetworkStream(listener.AcceptSocket))
                writer.Write(name)

                writers.Add(writer)

            End While

        Catch inpitoutputException As IOException
            MessageBox.Show("Server application Closing")

        End Try
    End Sub


    Public Sub sendCommand(ByVal command As String)
        For i As Integer = 0 To writers.Count
            Try
                Dim writer As BinaryWriter
                writer = CType(writers.Item(i), BinaryWriter)
                writer.Write(command)
                writer.Flush()
            Catch inputputputexception As Exception
            End Try
        Next
    End Sub

    Public Sub stopAll()
        For i As Integer = 1 To writers.Count
            Try

                Dim writer As BinaryWriter
                writer = CType(writers.Item(1), BinaryWriter)
                writer.Close()
                writers.Remove(1)
            Catch inputputputexception As Exception
            End Try
        Next
        listener.Stop()



    End Sub
End Class

the Client code :
Imports System.Net.Sockets
Imports System.Windows.Forms
Imports System.IO
Imports System.Threading
Public Class recieve

    Private reader As BinaryReader
    Private message As String = ""
    Private frmObject As frmMain
    ' Dim k As String = ""C:\Users\hamzah\Desktop\BVP\BVP_client\BVP.txt
    Private readthred As Thread
    Public Sub New(ByVal frmObject As frmMain)
        MyBase.New()
        Me.frmObject = frmObject
        readthred = New Thread(AddressOf runClinet)
        readthred.Start()

    End Sub

    Public Sub runClinet()
        Dim client As TcpClient
        Try
            client = New TcpClient()
            client.Connect("127.0.0.1", 5234)
            reader = New BinaryReader(client.GetStream())
            Try
                Dim Path As String
                Path = reader.ReadString
                frmMain.ListBox1.SelectedItem = Path' it give me exception here
               
                frmObject.Playlist.SelectedItem = frmObject.ListBox1.SelectedItem' and sometime here
                frmMain.AxWindowsMediaPlayer1.URL = Path
                frmObject.ListBox1.Items.Add(Path)
                frmObject.Playlist.Items.Add(Path)
                Try
                    While True
                        Path = reader.ReadString
                        Select Case Path
                            Case "1"
                                frmObject.AxWindowsMediaPlayer1.Ctlcontrols.pause()
                            Case "2"
                                frmObject.AxWindowsMediaPlayer1.Ctlcontrols.play()
                            Case "3"
                                frmObject.AxWindowsMediaPlayer1.Ctlcontrols.stop()
                        End Select
                    End While
                Catch ex As Exception
                End Try
            Catch inputoutputException As IOException
            Finally
            End Try
            Try
                frmObject.AxWindowsMediaPlayer1.Ctlcontrols.stop()
                reader.Close()
                client.Close()
            Catch exx As Exception
            End Try
        Catch inputoutputException As IOException
        End Try
    End Sub
End Class
Tags: Visual Basic, .NET, Networking, Network

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900