日期:2014-05-17  浏览次数:20827 次

请教个网络编程问题
我想实现个类似视频聊天程序,2个视频窗口1个显示本地1个显示网络传输过来的视频窗口,但是我现在思路不清楚应该怎么做,
谁能给我提供下思路那 还有用不用多线程那.



C# code

   //这是接收的 
                        private   void   RecvData() 
                { 
                          try 
                        { 
                                TcpListener   tcpList   =   new   TcpListener(IPAddress.Parse(ipName),   port); 
                                tcpList.Start(); 
                                sockets   =   tcpList.AcceptSocket(); 
                                ns   =   new   NetworkStream(sockets); 
                                BitmapImage   bitImage   =   new   BitmapImage(); 
                                bitImage.BeginInit(); 
                                bitImage.StreamSource   =   ns; 
                                bitImage.EndInit(); 
                                image2.Source   =   bitImage; 
                        } 
                        catch   (Exception   es) 
                        { 

                                es.Message.ToString(); 
                        } 
                } 


                    //这是发送 
                      private   void   SendData() 
                { 
                      
                        try 
                        {                           
                                myclient   =   new   TcpClient(ipName,   port); 
                                myns   =   myclient.GetStream(); 
                                mysw   =   new   BinaryWriter(myns); 
                                mysw.Write(result);                                 
                                mysw.Flush(); 
                                myns.Flush();                       
                                mysw.Close(); 
                                myns.Close(); 
                                myclient.Close(); 
                                
                        } 
                        catch   (Exception   es) 
                        { 
                                es.Message.ToString(); 
                        } 
                        

                
                } 




求帮看看代码怎么改

------解决方案--------------------
http://www.cnblogs.com/pinhao/archive/2012/04/12/2443842.html
我前几天抽空总结的,你可以参考下,网络编程的