我正在测试一个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

  • 使用Windows phone作为客户端连接Socket服务器 .

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
  • 结果显示:NotConnected或连接重置

一个 . 可以通过这种方式为Windows Phone工作吗?有什么我错过的吗?

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

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

感谢您的帮助 .