diff --git a/pcsx2/IPC.cpp b/pcsx2/IPC.cpp index f8bf30f463..fa26ec8ee5 100644 --- a/pcsx2/IPC.cpp +++ b/pcsx2/IPC.cpp @@ -42,7 +42,7 @@ #include "svnrev.h" #include "IPC.h" -SocketIPC::SocketIPC(SysCoreThread* vm, unsigned int slot = DEFAULT_PORT) +SocketIPC::SocketIPC(SysCoreThread* vm, unsigned int slot) : pxThread("IPC_Socket") { #ifdef _WIN32 @@ -85,11 +85,11 @@ SocketIPC::SocketIPC(SysCoreThread* vm, unsigned int slot = DEFAULT_PORT) char* tmp_socket; if (runtime_dir == NULL) - m_socket_name = tmp_socket = (char*)"/tmp/pcsx2.sock"; + m_socket_name = tmp_socket = (char*)"/tmp/" IPC_EMULATOR_NAME ".sock"; else - m_socket_name = tmp_socket = strcat(runtime_dir, "/pcsx2.sock"); + m_socket_name = tmp_socket = strcat(runtime_dir, "/" IPC_EMULATOR_NAME ".sock"); - if (slot != DEFAULT_PORT) + if (slot != IPC_DEFAULT_SLOT) { // maximum size of .%u char slot_ending[34]; diff --git a/pcsx2/IPC.h b/pcsx2/IPC.h index 7e7b6d67e2..1c4fd03790 100644 --- a/pcsx2/IPC.h +++ b/pcsx2/IPC.h @@ -18,6 +18,13 @@ #pragma once +// IPC uses a concept of "slot" to be able to communicate with multiple +// emulators at the same time, each slot should be unique to each emulator to +// allow PnP and configurable by the end user so that several runs don't +// conflict with each others +#define IPC_DEFAULT_SLOT 28011 +#define IPC_EMULATOR_NAME "pcsx2" + #include "Utilities/PersistentThread.h" #include "System/SysThreads.h" #ifdef _WIN32 @@ -29,7 +36,6 @@ using namespace Threading; class SocketIPC : public pxThread { - // parent thread typedef pxThread _parent; @@ -37,7 +43,6 @@ protected: #ifdef _WIN32 // 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. -#define DEFAULT_PORT 28011 SOCKET m_sock = INVALID_SOCKET; // the message socket used in thread's accept(). SOCKET m_msgsock = INVALID_SOCKET; @@ -200,7 +205,7 @@ public: bool m_end = true; /* Initializers */ - SocketIPC(SysCoreThread* vm, unsigned int slot = DEFAULT_PORT); + SocketIPC(SysCoreThread* vm, unsigned int slot = IPC_DEFAULT_SLOT); virtual ~SocketIPC(); }; // class SocketIPC