本文介绍了clinet/服务器应用程序中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了播放器,用于将视频从服务器流式传输(广播)到Lan网络中的​​clinet,我的问题是,当我将视频的URL发送到clinet时,它将其接收并添加到播放列表中,但是当我要播放时演出

I have created player to stream(broadcast) a video from server to clinet in Lan network,my problem is when I send URL of the video to clinet it take it and add to playlist but when I want to play it message box show''s

"InvalidArgument value of 0 is not valid for selecteD Index parameter name:selectedIndexSystem.windows.form "


我将使用客户端和服务器的代码,但是我已经确定了将在客户端播出的视频.
这是 客户端代码


I will but the code of client and server but the I have determine the video which will be broacast in client side.
this is the client code

Imports System.Net.Sockets
Imports System.Windows.Forms
Imports System.IO
Imports System.Threading
Public Class recieve

    Private output As NetworkStream
    Private reader As BinaryReader
    Private writer As BinaryWriter
    Private message As String = ""
    Private readthred As Thread
        Public Sub runClinet()
        Dim clinet As TcpClient
        Try
            clinet = New TcpClient()
            clinet.Connect("localhost", 5432)
            output = clinet.GetStream()
            writer = New BinaryWriter(output)
            reader = New BinaryReader(output)
            Try
                ''    Do
                Dim r As String

                message = "C:\Users\Public\Videos\Sample Videos\Wildlife.wmv"
                r = message
                frmMain.Playlist.Items.Add(r)

                frmMain.Playlist.SelectedItem = r
                frmMain.AxWindowsMediaPlayer1.URL = frmMain.Playlist.SelectedIndex


                ''Loop While message <> "Server>>> Terminate"
            Catch inputoutputException As IOException
                MessageBox.Show("Clinet application Closing")
            Finally
                writer.Close()
                reader.Close()
                output.Close()
                clinet.Close()
            End Try
        Catch inputoutputException As IOException
            MessageBox.Show("Clinet application Close")
        End Try
    End Sub
End Class


这是服务器代码:


this is the server code :

Imports System.Net.Sockets
Imports System.Threading
Imports System.Windows.Forms
Imports System.IO

Public Class broadcast

    Private conn As Socket
    Private readthread As Thread
    Private socketstream As NetworkStream
    Private writer As BinaryWriter
    Private reader As BinaryReader
       Public Sub RunServer()
        Dim listener As New TcpListener(5432)
        Dim counter As Integer = 1
        Try
            listener.Start()
            While True
                Dim b As String
                b = frmMain.Playlist.SelectedIndex
                conn = listener.AcceptSocket
                socketstream = New NetworkStream(conn)
                writer = New BinaryWriter(socketstream)
                reader = New BinaryReader(socketstream)
                Dim theReplay As String = ""
                Try
                    ''  Do
                    theReplay = reader.ReadString

                    '' Loop While (theReplay <> "CLINET>>> TERMINATE" _
                    ''           AndAlso conn.Connected)
                Catch inputputputexception As IOException
            MessageBox.Show("Clinet application closing")
        Finally
            writer.Close()
            reader.Close()
            socketstream.Close()
            conn.Close()
            counter += 1
        End Try
            End While
        Catch inpitoutputException As IOException
            MessageBox.Show("Server application Closing")
        End Try
    End Sub

End Class


感谢您的帮助

[edit]大写字母,一些拼写,虚假的内联代码和删除线-原始格里夫[/edit]


Thanks for help

[edit]Capitalization, some spelling, spurious inline code and strikeout removed - OriginalGriff[/edit]

推荐答案


这篇关于clinet/服务器应用程序中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 14:29