how to make voice chat using external ip c#
I want to make voice chat using external ip over Internet using any protocol but using external ip and local ip using c# I have no problem in voice just my problem how to send and receive buffer
private Socket r;
private Thread t;
r = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
t = new Thread(new ThreadStart(Voice_In));
#region Voice_In()
private void Voice_In()
{
byte[] br;
r.Bind(new IPEndPoint(IPAddress.Any, int.Parse(this.textBox2.Text)));
while (true)
{
br = new byte[16384];
r.Receive(br);
m_Fifo.Write(br, 0, br.Length);
}
}
#endre开发者_开发问答gion
#region Voice_Out()
private void Voice_Out(IntPtr data, int size)
{
//for Recorder
if (m_RecBuffer == null || m_RecBuffer.Length < size)
m_RecBuffer = new byte[size];
System.Runtime.InteropServices.Marshal.Copy(data, m_RecBuffer, 0, size);
//Microphone ==> data ==> m_RecBuffer ==> m_Fifo
r.SendTo(m_RecBuffer, new IPEndPoint(IPAddress.Parse(this.textBox1.Text), int.Parse(this.textBox3.Text)));
}
#endregion
Well if your only issue is to network data between two ip addresses, you should just focus on the network part. Do you want to use WCF or TCP directly? In the second case, System.Net.Sockets namespace has classes like TcpClient, TcpListener, UdpClient...
精彩评论