mirror of https://github.com/PCSX2/pcsx2.git
IPC: add slot init
This commit is contained in:
parent
b6246a7ba4
commit
119942b7a4
|
@ -42,7 +42,7 @@
|
||||||
#include "svnrev.h"
|
#include "svnrev.h"
|
||||||
#include "IPC.h"
|
#include "IPC.h"
|
||||||
|
|
||||||
SocketIPC::SocketIPC(SysCoreThread* vm)
|
SocketIPC::SocketIPC(SysCoreThread* vm, unsigned int slot = DEFAULT_PORT)
|
||||||
: pxThread("IPC_Socket")
|
: pxThread("IPC_Socket")
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -66,7 +66,7 @@ SocketIPC::SocketIPC(SysCoreThread* vm)
|
||||||
server.sin_family = AF_INET;
|
server.sin_family = AF_INET;
|
||||||
// localhost only
|
// localhost only
|
||||||
server.sin_addr.s_addr = inet_addr("127.0.0.1");
|
server.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||||
server.sin_port = htons(PORT);
|
server.sin_port = htons(slot);
|
||||||
|
|
||||||
if (bind(m_sock, (struct sockaddr*)&server, sizeof(server)) == SOCKET_ERROR)
|
if (bind(m_sock, (struct sockaddr*)&server, sizeof(server)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
|
@ -75,8 +75,6 @@ SocketIPC::SocketIPC(SysCoreThread* vm)
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// XXX: go back whenever we want to have multiple IPC instances with
|
|
||||||
// multiple emulators running and make this a folder
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
char* runtime_dir = std::getenv("TMPDIR");
|
char* runtime_dir = std::getenv("TMPDIR");
|
||||||
#else
|
#else
|
||||||
|
@ -84,10 +82,21 @@ SocketIPC::SocketIPC(SysCoreThread* vm)
|
||||||
#endif
|
#endif
|
||||||
// fallback in case macOS or other OSes don't implement the XDG base
|
// fallback in case macOS or other OSes don't implement the XDG base
|
||||||
// spec
|
// spec
|
||||||
|
char* tmp_socket;
|
||||||
|
|
||||||
if (runtime_dir == NULL)
|
if (runtime_dir == NULL)
|
||||||
m_socket_name = (char*)"/tmp/pcsx2.sock";
|
m_socket_name = tmp_socket = (char*)"/tmp/pcsx2.sock";
|
||||||
else
|
else
|
||||||
m_socket_name = strcat(runtime_dir, "/pcsx2.sock");
|
m_socket_name = tmp_socket = strcat(runtime_dir, "/pcsx2.sock");
|
||||||
|
|
||||||
|
if (slot != DEFAULT_PORT)
|
||||||
|
{
|
||||||
|
// maximum size of .%u
|
||||||
|
char slot_ending[34];
|
||||||
|
sprintf(slot_ending, ".%u", slot);
|
||||||
|
m_socket_name = strcat(tmp_socket, slot_ending);
|
||||||
|
free(tmp_socket);
|
||||||
|
}
|
||||||
|
|
||||||
struct sockaddr_un server;
|
struct sockaddr_un server;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ protected:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// windows claim to have support for AF_UNIX sockets but that is a blatant lie,
|
// windows claim to have support for AF_UNIX sockets but that is a blatant lie,
|
||||||
// their SDK won't even run their own examples, so we go on TCP sockets.
|
// their SDK won't even run their own examples, so we go on TCP sockets.
|
||||||
#define PORT 28011
|
#define DEFAULT_PORT 28011
|
||||||
SOCKET m_sock = INVALID_SOCKET;
|
SOCKET m_sock = INVALID_SOCKET;
|
||||||
// the message socket used in thread's accept().
|
// the message socket used in thread's accept().
|
||||||
SOCKET m_msgsock = INVALID_SOCKET;
|
SOCKET m_msgsock = INVALID_SOCKET;
|
||||||
|
@ -200,7 +200,7 @@ public:
|
||||||
bool m_end = true;
|
bool m_end = true;
|
||||||
|
|
||||||
/* Initializers */
|
/* Initializers */
|
||||||
SocketIPC(SysCoreThread* vm);
|
SocketIPC(SysCoreThread* vm, unsigned int slot = DEFAULT_PORT);
|
||||||
virtual ~SocketIPC();
|
virtual ~SocketIPC();
|
||||||
|
|
||||||
}; // class SocketIPC
|
}; // class SocketIPC
|
||||||
|
|
Loading…
Reference in New Issue