为什么不从 WinRT 应用程序(在 StreamSocket 上)连接到 win32 应用程序(在 QTcpSocket 上) [英] Why not connect from WinRT app(on StreamSocket) to win32 app(on QTcpSocket)

查看:26
本文介绍了为什么不从 WinRT 应用程序(在 StreamSocket 上)连接到 win32 应用程序(在 QTcpSocket 上)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发带有 Metro 应用程序和 win32 桌面的 Windows 8.1 聊天客户端应用程序.在 Tcp 套接字上未从 winrt 应用程序连接到 win32 应用程序的问题 - 异常连接失败,错误无法从其他计算机回复.有什么问题?

I'm developing a Windows 8.1 chat client app with metro app and win32 desktop. Problem in not connected from winrt app to win32 app on Tcp socket - exception connected failed with error not reply from other computer. What's the problem?

我正在语言环境 mashine 上进行测试:

I'm testing on the locale mashine:

void Connector::ConnectSocketTsp(void)
{
    socket = ref new StreamSocket();

    rootPage->NotifyUser("Connecting to ...", NotifyType::StatusMessage);

    {
        HostName^ serverHost = ref new HostName("127.0.0.1");   //("localhost");
        // Connect...
        create_task(socket->ConnectAsync(
            serverHost, "15500", SocketProtectionLevel::PlainSocket)).then([this](task<void> previousTask)
        {
            try
            {
                previousTask.get();
                rootPage->NotifyUser("Connected", NotifyType::StatusMessage);

                m_reader = ref new DataReader(socket->InputStream);
                m_reader->InputStreamOptions = InputStreamOptions::ReadAhead;
                m_writer = ref new DataWriter(socket->OutputStream);

                ReceiveStringLoop(m_reader, socket);

            }
            catch (Exception^ exception)
            {
                rootPage->NotifyUser("Connect failed with error: " + exception->Message, NotifyType::ErrorMessage);
            }
        });
    }
}

exception->Message = "尝试连接失败,因为在所需的时间内从另一台计算机获得所需的响应已断开连接或由于错误的响应已建立连接已连接的计算机."

exception->Message = "An attempt to connect was unsuccessful because from another computer in the required time you get the desired response has been disconnected or established connection due to an incorrect response is already connected computer."

和翻译消息的服务:

void start()
{
    logMessage(QString("Start service"), QtServiceBase::Information);

    QCoreApplication *app = application();

    daemon = new ClientSocket(15500, app);

    if ( !daemon->listen(QHostAddress::LocalHost, 15500) )      // QHostAddress::Any
        logMessage(QString("Failed to bind to port %1").arg(daemon->serverPort()), QtServiceBase::Error);       
    else
        logMessage(QString("Success to bind to port %1").arg(daemon->serverPort()), QtServiceBase::Information);

    if ( !daemon->isListening() )
    {
        logMessage(QString("Failed to bind to port %1").arg(daemon->serverPort()), QtServiceBase::Error);
        app->quit();
    }   
}

Telnet 成功连接到 127.0.0.1 15500...

Telnet successfully connects to 127.0.0.1 15500...

推荐答案

Windows 应用商店应用默认被阻止连接到同一台机器上的其他应用.

Windows Store apps by default are blocked from connecting to other apps on the same machine.

这个块可以在调试过程中被抑制,或者(从 Windows 8.1 更新开始)被旁加载的应用程序绕过(chue x 的链接和无法完成"评论对于 Windows 8 是正确的,但现在已经过时了).

This block can be suppressed during debugging or (as of the Windows 8.1 Update) bypassed for side-loaded apps (chue x's links and "can't be done" comment are true for Windows 8, but now out of date).

对于通过商店部署的应用程序,没有可认证的方式来回环.

There is no certifiable way to loop back for an app deployed through the store.

请参阅如何启用环回和排除网络隔离故障(Windows 应用商店应用)在旁加载的 Windows 应用商店应用

这篇关于为什么不从 WinRT 应用程序(在 StreamSocket 上)连接到 win32 应用程序(在 QTcpSocket 上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆