使用TCP套接字客户端的WP应用无法连接到套接字服务器

时间:2013-02-21 07:22:12

标签: windows-phone-7.1 windows-phone-8

我正在测试一个TCP套接字客户端应用程序与wiFi环境中的Socket-Server进行通信。

1。)我正在使用VS2005为Socket-Server创建Console App(Netframework v2.0)

1.1):使用IPAddress:192.168.1.100和portNo 3456

在PC中启动Console App
  1. 使用Windows phone作为客户端连接Socket服务器。
  2. 2.0)在手机中设置wifi连接。

    2.1)启动应用程序以在Wifi中连接服务器

    连接服务器的客户端代码(无编译错误)

    
    //-- taking idea from :creating a TCP Socket client 
    
    http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202858(v=vs.105).aspx
    
    
                // create endpoint
    
                var ipAddress = IPAddress.Parse(hostName);
                var endpoint = new IPEndPoint(ipAddress, portNumber);  // ( 192.168.1.100 , 3456)
    
                // Create a stream-based, TCP socket using the InterNetwork Address Family. 
                _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);       
    
                SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs();            
                socketEventArg.RemoteEndPoint = endpoint;
    
               ...... to do task here
    
    
    1. 结果显示:NotConnected或Connection Reset
    2. 一个。可以通过这种方式为Windows Phone工作吗?我有什么遗漏的吗?

      但是,它适用于WP模拟器。

      湾WP的Netframework v4中的套接字版本与WinForm的套接字版本2.0或VS2008中的VS25 / Netframework v3.5中的控制台应用程序之间的通信有任何问题吗?

      感谢您的帮助。

0 个答案:

没有答案
相关问题