openMSX control using a socket

Por sjoerd

Hero (602)

Imagen del sjoerd

02-03-2014, 12:32

I'd like to control openMSX using a socket, but openMSX does not want to talk to me Question

Let's assume we have found the port number is 9938 so the test program does not become unnecessary large. With openMSX 0.6.2 this program prints [openmsx-output] as expected, but newer versions like openMSX 0.10.0 just reset the connection or something.

So, how do I convince newer openMSXes to talk to me using a socket?

#include [iostream]
#include [winsock2.h]
#pragma comment(lib,"ws2_32.lib")

int main(void)
{
    WSADATA WsaDat;
    WSAStartup(MAKEWORD(2,2), &WsaDat);
	
    SOCKET Socket = socket(AF_INET, SOCK_STREAM, 0);
	
    SOCKADDR_IN SockAddr;
    SockAddr.sin_port = htons(9938);
    SockAddr.sin_family = AF_INET;
    SockAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
	
    if (connect(Socket, (SOCKADDR*)(&SockAddr), sizeof(SockAddr)) == -1) std::cout << "No connection\n";

    char buffer[1000];
    memset(buffer, 0, 999);

    recv(Socket, buffer, 1000, 0);
    std::cout << buffer;

    closesocket(Socket);

    system("PAUSE");
    WSACleanup();
    return 0;
}
Login sesión o register para postear comentarios

Por Manuel

Ascended (18392)

Imagen del Manuel

02-03-2014, 14:17

On Windows, you have to use SSPI (as of openMSX 0.7.1, I think), see the code in the openmsx-debugger for instance. Direct link: https://sourceforge.net/p/openmsx/debugger/ci/master/tree/sr... which uses stuff from https://sourceforge.net/p/openmsx/debugger/ci/master/tree/sr...

Por sjoerd

Hero (602)

Imagen del sjoerd

02-03-2014, 15:23

Ah. Thanks.

Got it working now.

Por Manuel

Ascended (18392)

Imagen del Manuel

02-03-2014, 15:31

Great to hear that! What are you making? Smile

Por sjoerd

Hero (602)

Imagen del sjoerd

02-03-2014, 15:35

A game level editor. I want to use openMSX to easily test the levels, and change them on the fly.

Por Manuel

Ascended (18392)

Imagen del Manuel

02-03-2014, 20:09

Cool, now you made me curious what the levels are for!