日期:2014-05-18  浏览次数:20800 次

使用agsXMPP时出现的问题(急,可加分)
未处理 System.IO.IOException
  Message="无法将数据写入传输连接: 由于套接字没有连接并且(当使用一个 sendto 调用发送数据报套接字时)没有提供地址,发送或接收数据的请求没有被接受。。"
  Source="MeetingClient"
  StackTrace:
  在 MeetingClient.MainFrm.con_OnError(Object sender, Exception ex) 位置 E:\项目\公司项目\视频会议\客户端\客户端\MeetingClient\MeetingClient\MainFrm.cs:行号 300
  在 agsXMPP.XmppConnection.FireOnError(Object sender, Exception ex)
  在 agsXMPP.XmppConnection.SocketOnError(Object sender, Exception ex)
  在 agsXMPP.XmppClientConnection.SocketOnError(Object sender, Exception ex)
  在 agsXMPP.net.BaseSocket.FireOnError(Exception ex)
  在 agsXMPP.net.ClientSocket.EndConnect(IAsyncResult ar)
  在 System.Net.LazyAsyncResult.Complete(IntPtr userToken)
  在 System.Net.ContextAwareResult.CompleteCallback(Object state)
  在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
  在 System.Net.ContextAwareResult.Complete(IntPtr userToken)
  在 System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
  在 System.Net.Sockets.Socket.ConnectCallback()
  在 System.Net.Sockets.Socket.RegisteredWaitCallback(Object state, Boolean timedOut)
  在 System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)


我用客户端连接服务器的时候报这个错,~我服务器代码
C# code

          private void button1_Click(object sender, EventArgs e)
        {
            isStart = true;
            this.button1.Enabled = false;
            myThread = new Thread(new ThreadStart(Linsten));
            myThread.Start();
            this.button2.Enabled = true;
        }

   private void Linsten()
        {
            iep = new IPEndPoint(IPAddress.Any, 6888);
            //  IPHostEntry ieh = Dns.GetHostEntry(Dns.GetHostName());

            //   iep = new IPEndPoint(ieh.AddressList[0], 6888);
            listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            try
            {
                //将IP主机IP绑定于Socket;
                listener.Bind(iep);


                while (isStart)
                {
                    listener.Listen(50);
                    allDone.Reset();
                    listener.BeginAccept(new AsyncCallback(AcceptCallback), null);
                    allDone.WaitOne();
                }
            }
            catch
            {
                this.button2.Enabled = false;
                this.button1.Enabled = true;
                MessageBox.Show("服务器6888端口被占用,请重新启动服务器后再试");
            }
        }
        private void AcceptCallback(IAsyncResult ar)
        {
            allDone.Set();
            Socket newSock = listener.EndAccept(ar);          
          
            agsXMPP.XmppSeverConnection con = new agsXMPP.XmppSeverConnection(this, newSock);
        }

现在的问题是我用127.0.0.1连接,一切正常,用192.168.0.100(我内网IP)连接,连接失败,报如上的错,高手帮我解决下,OK?




------解决方案--------------------
期待高手吧。。。。。。
------解决方案--------------------



 这东西好长时间没有搞过了,忘记完了,