本文介绍了使用C#.net在LAN上进行语音广播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在开发一个使用Direct-X进行语音聊天的C#.Net应用程序。



我能够通过特定IP发送或接收语音,但我不知道如何通过LAN向所有可用IP广播语音。

我必须只向所有IP发送语音消息,而不是从他们那里接收。



提前感谢。

Hi,

I'm developing a C#.Net application for Voice Chatting using Direct-X.

I'm able to send or receive voice over a particular IP, but I don't know how to broadcast voice over LAN to all available IP's.
I have to only send voice message to all IP's, not to receive from them.

Thank's in advance.

推荐答案

//UDP Listener(client)
            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            System.Net.IPEndPoint iep = new System.Net.IPEndPoint(System.Net.IPAddress.Any, 777);
            s.Bind((System.Net.EndPoint)iep);
            byte[] data = new byte[1024];

            s.Receive(data);

            //UDP Broadcaster(server)
            Socket broadcaster = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            System.Net.IPEndPoint iep2 = new System.Net.IPEndPoint(System.Net.IPAddress.Broadcast, 777);
            s.Connect((System.Net.EndPoint)iep2);
            byte[] data2 = new byte[1024];

            broadcaster.Send(data2);




这篇关于使用C#.net在LAN上进行语音广播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 08:47