如题

解决方案 »

  1.   

    服务端
      // Set the TcpListener on port 13000.
                    IPAddress localAddr = IPAddress.Parse("127.0.0.1");                // TcpListener server = new TcpListener(port);
                    listener = new TcpListener(localAddr, 12345);                // Start listening for client requests.
                    listener.Start();                // Enter the listening loop.
                    while(true) 
                    {
                        Console.Write("Waiting for a connection... ");                    // Perform a blocking call to accept requests.
                        // You could also user server.AcceptSocket() here.
                        TcpClient client = listener.AcceptTcpClient();
                        Console.WriteLine("Connected!");
    }
      

  2.   

    客户端
     IPAddress hostAddress = new IPAddress(new byte[] { 192,168,1,230}); s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);           s.Connect(hostAddress,12345);192.168.1.230是服务段IP地址 运行到 s.Connect(hostAddress,12345) 时候出现"由于目标机器积极拒绝,无法连接."错误。着急!!!!!!!!!!!!!!!!!!!!!!!!!
      

  3.   

    haha, i have run into the same situation.pls try to run another service that your application is required.you can use FireDaemon Service Manager software to run services.
      

  4.   

    telnet 一下你连接用的端口
      

  5.   

    我遇到一个更奇怪的问题 
    我用web写的tcp传输 
    客户都收不到数据 
    但发送没出错 
    同样的代码在winform就没有任何问题 这是什么原因呢
      

  6.   

    如果在没有断开连接的情况下,再执行connect操作,就会出现这种错误
      

  7.   

    haitao5676(笑纹) 说的对,端口不对。