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?
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 = "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."
And service to translate messages:
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 successfully connects to 127.0.0.1 15500...