Skip to content

Commit

Permalink
Using a programmer specified port number now. And we get to our first…
Browse files Browse the repository at this point in the history
… qSupported string! :)
  • Loading branch information
nacnud-sco committed May 5, 2024
1 parent c4b9687 commit 0b7233d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Src/BeebWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5375,6 +5375,9 @@ class _6502SimControl : public ISimulationControl {
// Target utilities
uint32_t htotl(uint32_t hostVal) override;
uint32_t ttohl(uint32_t targetVal) override;

private:
bool m_serverRunning{ false };
};


Expand Down Expand Up @@ -5486,6 +5489,7 @@ bool _6502SimControl::isServerRunning() {
void _6502SimControl::setServerRunning(bool status) {
// TODO: Implement setServerRunning functionality
// ...
m_serverRunning = status;
}

// Target utilities
Expand All @@ -5506,7 +5510,7 @@ void BeebWin::GdbStartServer()
{
static bool serverStarted{ false };
static _6502SimControl simControl = _6502SimControl();
static GdbServer gdbServer(/*Simulation controller =*/&simControl, /*tcp port=*/51000);
static GdbServer gdbServer(/*Simulation controller =*/&simControl, /*tcp port=*/17901);

if (serverStarted == false) {
static std::thread gdbThread(&GdbServer::serverThread, gdbServer);
Expand Down
2 changes: 1 addition & 1 deletion Src/gdb_server/headers/rsp_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class RspConnection {


//! The port number to listen on
int portNum;
int m_portNum;

//! The service name to listen on
const char* serviceName;
Expand Down
9 changes: 6 additions & 3 deletions Src/gdb_server/rsp_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <iomanip>
#include <rsp_connection.hpp>

#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdlib.h>
Expand Down Expand Up @@ -66,7 +65,7 @@ using namespace std;
//! @param[in] _serviceName The service name to use (if PortNum == 0).
//-----------------------------------------------------------------------------
void RspConnection::rspInit(int _portNum, const char* _serviceName) {
portNum = _portNum;
m_portNum = _portNum;
serviceName = _serviceName;
m_clientFd = -1;
} // init ()
Expand Down Expand Up @@ -103,8 +102,12 @@ bool RspConnection::rspConnectWindows()
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;

constexpr uint8_t MAX_PORT_NUMBER_LEN{40};
static char portNumber[MAX_PORT_NUMBER_LEN];
snprintf(portNumber,MAX_PORT_NUMBER_LEN,"%d", m_portNum);

// Resolve the server address and port
iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result);
iResult = getaddrinfo("localhost", portNumber, &hints, &result);
if (iResult != 0) {
printf("getaddrinfo failed with error: %d\n", iResult);
WSACleanup();
Expand Down

0 comments on commit 0b7233d

Please sign in to comment.