Windows 8 app如何连接到Socket服务器 [英] Windows 8 app how to connect to Socket server
本文介绍了Windows 8 app如何连接到Socket服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用此示例完成了一个服务器如何使用SocketAsyncEventArgs类 [ ^ ]
视觉工作室2010和.net 4.0中的
。
现在我正试图使用StreamSocket从Windows 8应用程序连接到它,但我收到被拒绝的消息。
这里是客户代码:
i have done a server using this example How To Use the SocketAsyncEventArgs Class[^]
in visual studio 2010 and .net 4.0.
Now i'm trying to connect to it from a windows 8 app using StreamSocket but i'm getting a "Acces denied" message.
here is the Client code:
private StreamSocket streamSocket;
public string Server = "192.168.0.101";
public int Port = 9900;
public async void Connect()
{
streamSocket = new StreamSocket();
Connect();
try
{
await streamSocket.ConnectAsync(
new Windows.Networking.HostName(Server),
Port.ToString()); // getting Acces Denied here
DataReader reader = new DataReader(streamSocket.InputStream);
reader.InputStreamOptions = InputStreamOptions.Partial;
while (true)
{
var bytesAvailable = await reader.LoadAsync(1000);
var byteArray = new byte[bytesAvailable];
reader.ReadBytes(byteArray);
}
}
catch (Exception e)
{
MessageBox(e.StackTrace);
}
}
如何解决问题?是否有其他方式发送和接收消息?
谢谢,
How to fix the problem? Is there another way to send and receive messages?
Thanks,
推荐答案
请添加专用网络( Manifest中的客户端和服务器)功能
谢谢,
Bilaal
Please add Private Networks (Client & Server) capability in Manifest
Thanks,
Bilaal
这篇关于Windows 8 app如何连接到Socket服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文