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