我正在查看位于此处的NAUDIO库的演示项目:
他们有一个当前通过UDP运行的网络流的示例。我想知道我需要做什么才能转换为运行TCP。我需要在TCP上运行以确保每个数据包到达服务器:
private void Connect(IPEndPoint endPoint, int inputDeviceNumber, INetworkChatCodec codec)
{
waveIn = new WaveIn();
waveIn.BufferMilliseconds = 50;
waveIn.DeviceNumber = inputDeviceNumber;
waveIn.WaveFormat = codec.RecordFormat;
waveIn.DataAvailable += waveIn_DataAvailable;
waveIn.StartRecording();
udpSender = new UdpClient();
udpListener = new UdpClient();
//endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7080);
// To allow us to talk to ourselves for test purposes:
// http://stackoverflow.com/questions/687868/sending-and-receiving-udp-packets-between-two-programs-on-the-same-computer
//udpSender.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
udpListener.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
//udpSender.Client.Bind(endPoint);
udpListener.Client.Bind(endPoint);
udpSender.Connect(endPoint);
waveOut = new WaveOut();
waveProvider = new BufferedWaveProvider(codec.RecordFormat);
waveOut.Init(waveProvider);
waveOut.Play();
connected = true;
ListenerThreadState state = new ListenerThreadState() { Codec = codec, EndPoint = endPoint };
ThreadPool.QueueUserWorkItem(this.ListenerThread, state);
}
感谢任何帮助。