The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Are TCP sockets compatible between Visual studio and Qt creator??
I am trying to build communication between VS windows and QT Ubuntu via TCP/IP protocol. Both client and server codes are working individually within their own IDEs . But by taking client from VS and server from Qt ,the client is unable to communicate with server. Please help me to find out the problem.
Client code from Visual studio express 2012
define WIN32_LEAN_AND_MEAN
include <windows.h>
include <winsock2.h>
include <ws2tcpip.h>
include <stdlib.h>
include <stdio.h>
// Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib
pragma comment (lib, "Ws2_32.lib")
pragma comment (lib, "Mswsock.lib")
pragma comment (lib, "AdvApi32.lib")
define DEFAULT_BUFLEN 512
define DEFAULT_PORT "27015"
int __cdecl main(int argc, char **argv)
{
WSADATA wsaData;
SOCKET ConnectSocket = INVALID_SOCKET;
struct addrinfo *result = NULL,
*ptr = NULL,
hints;
char *sendbuf = "this is a test";
char recvbuf[DEFAULT_BUFLEN];
int iResult;
int recvbuflen = DEFAULT_BUFLEN;
// Validate the parameters
if (argc != 2) {
printf("usage: %s server-name\n", argv[0]);
return 1;
}
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0) {
printf("WSAStartup failed with error: %d\n", iResult);
return 1;
}
ZeroMemory( &hints, sizeof(hints) );
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
// Resolve the server address and port
iResult = getaddrinfo(argv[1], DEFAULT_PORT, &hints, &result);
if ( iResult != 0 ) {
printf("getaddrinfo failed with error: %d\n", iResult);
WSACleanup();
return 1;
}
// Attempt to connect to an address until one succeeds
for(ptr=result; ptr != NULL ;ptr=ptr->ai_next) {
// Create a SOCKET for connecting to server ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); if (ConnectSocket == INVALID_SOCKET) { printf("socket failed with error: %ld\n", WSAGetLastError()); WSACleanup(); return 1; } // Connect to server. iResult = connect( ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen); if (iResult == SOCKET_ERROR) { closesocket(ConnectSocket); ConnectSocket = INVALID_SOCKET; continue; } break;
}
freeaddrinfo(result);
if (ConnectSocket == INVALID_SOCKET) {
printf("Unable to connect to server!\n");
WSACleanup();
return 1;
}
// Send an initial buffer
iResult = send( ConnectSocket, sendbuf, (int)strlen(sendbuf), 0 );
if (iResult == SOCKET_ERROR) {
printf("send failed with error: %d\n", WSAGetLastError());
closesocket(ConnectSocket);
WSACleanup();
return 1;
}
printf("Bytes Sent: %ld\n", iResult);
closesocket(ConnectSocket);
WSACleanup();
return 0;
}
Server code from QT creator 4
server.h
include
include
include
include
class Server: public QObject
{
Q_OBJECT
public:
Server(QObject * parent = 0);
~Server();
public slots:
void acceptConnection();
void startRead();
//void Server::sendData(QTcpSocket* client, QString data);
private:
QTcpServer server;
QTcpSocket* client;
};
main.cpp
include "server.h"
include <qcoreapplication.h>
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
Server server;
return app.exec();
}
server.cpp
include "server.h"
include
using namespace std;
Server::Server(QObject* parent): QObject(parent)
{
connect(&server, SIGNAL(newConnection()),
this, SLOT(acceptConnection()));
server.listen(QHostAddress::Any, 27015);
}
Server::~Server()
{
server.close();
}
void Server::acceptConnection()
{
client = server.nextPendingConnection();
connect(client, SIGNAL(readyRead()),
this, SLOT(startRead()));
}
void Server::startRead()
{
char buffer[512] = {0};
client->read(buffer, client->bytesAvailable());
cout << buffer << endl;
client->close();
}