Hey, i have a problem with TCP-Server.
I can send the input from microphone with a TCP-Client but the TCP-Server cannot play, because fast cames the error: "buffer full".
I have searched but i didn't found a solution and i have asked in two forums, one user said to ask here.
Code:
TCP-Server:
Private Sub MainServer()
TCP_Server.Start()
Dim bytes(1024) As Byte
Dim Received_Message As String = Nothing
While True
Dim client As TcpClient = TCP_Server.AcceptTcpClient()
Dim MicrosoftADPCM_Codec As INetworkChatCodec = New MicrosoftADPCM()
Dim stream As NetworkStream = client.GetStream
waveOut = New WaveOut()
waveProvider = New BufferedWaveProvider(MicrosoftADPCM_Codec.RecordFormat)
waveOut.Init(waveProvider)
waveOut.Play()
Dim i As Int32 = stream.Read(bytes, 0, bytes.Length)
While (i <> 0)
Dim decoded As Byte() = MicrosoftADPCM_Codec.Decode(bytes, 0, i)
waveProvider.AddSamples(decoded, 0, decoded.Length)
End While
End While
TCP_Server.Stop()
End Sub
TCP-Client:
Dim TCP_Client As New TcpClient("IP", "PORT")
Dim stream As Stream = TCP_Client.GetStream
Call_Stream = stream
Dim MicrosoftADPCM_Codec As INetworkChatCodec = New MicrosoftADPCM()
selectedCodec = MicrosoftADPCM_Codec
waveIn = New WaveIn()
waveIn.BufferMilliseconds = 50
waveIn.DeviceNumber = comboBoxInputDevices.SelectedIndex
waveIn.WaveFormat = MicrosoftADPCM_Codec.RecordFormat
AddHandler waveIn.DataAvailable, AddressOf waveIn_DataAvailable
waveIn.StartRecording()
waveIn_DataAvailable:
Private Sub waveIn_DataAvailable(sender As Object, e As WaveInEventArgs)
Dim encoded As Byte() = selectedCodec.Encode(e.Buffer, 0, e.BytesRecorded)
Call_Stream.Write(encoded, 0, encoded.Length)
End Sub
Thank you for any replies.