Page 1 of 1

RetroNET TCP Server

Posted: Fri Mar 31, 2023 2:12 am
by DJ Sures
NABULIB 2023.03.30.00 has been updated. Specifically, RetroNET-FileStore.c and RetroNET-FileStore.h.

This works with the latest Internet Adapter (2023.03.30.00). The feature must be enabled in the settings window under RetroNET. Once the TCP RetroNET Server is enabled, it will accept Telnet or any TCP connection.

Example application for CPM: https://github.com/DJSures/NABU-LIB/tre ... P%20Server

The new commands are...

Code: Select all

// **************************************************************************************************************
//
// TCP SERVER
//
// **************************************************************************************************************

// **************************************************************************
// Get the number of clients connected to the IA TCP Server
// **************************************************************************
uint8_t rn_TCPServerClientCnt();


// **************************************************************************
// Get the length of readable data on the TCP Server connection.
// **************************************************************************
uint8_t rn_TCPServerAvailable();

// **************************************************************************
// Read data from the specified tcp server connection
// 
// - buffer is a pointer to a buffer that the data will be written to.
// - bufferOffset is the offset within the buffer where the data will be written. Use 0 if you're
//   writing to the beginning of the buffer, for example.
// - readLength is the amount of data that you will be reading.
// 
// Returns: the number of bytes read
// **************************************************************************
uint8_t rn_TCPServerRead(uint8_t* buffer, uint16_t bufferOffset, uint8_t readLength);

// **************************************************************************
// Write data to all clients that are connected to the TCP Server..
// 
// - dataOffset is the offset of the data that will be written
// - dataLen is the length of data that will be written 
// - data is a pointer to the data
//
// **************************************************************************
void rn_TCPServerWrite(uint16_t dataOffset, uint8_t dataLen, uint8_t* data);

Re: RetroNET TCP Server

Posted: Wed Jul 23, 2025 9:07 pm
by AGMS
I was wondering how to get output redirection to work in non CP/M mode, thought of asking, but first looked at the Telnet source code, and found that the magic words to search for are "TCP Server" (which is in RetroNET-FileStore.h). Anyone already used this to write some debug printf() replacements that output to telnet? Great for debugging while the graphical display is up and you aren't building for CP/M (that gives you an extra 10KB of RAM!).

Re: RetroNET TCP Server - Read Line #n?

Posted: Sun Nov 30, 2025 4:27 pm
by AGMS
While trying out the slideshow in MAME, I finally realised why you have these seemingly inefficient functions (not a sequential read, not a plain read line from current position) in RetroNet:

Code: Select all

uint16_t rn_fileHandleLineCount(uint8_t fileHandle);
uint16_t rn_fileHandleGetLine(uint8_t fileHandle, uint16_t lineNumber, uint8_t *buffer);
It's so you can implement the slide show list of song files and music files. With 10K music files, even loading just the file names into memory would use more than the 64K Nabu has. So instead, you have a file on the server listing all songs, get the total line count of that file, pick a random number from 0 to the number of lines - 1 (not sure if rn_fileHandleGetLine is zero based), and you can read just that file name from the listing. The server does all the work of reading things in and counting lines. Smart!

Though it uses the Nabu Internet Adapter server's platform idea of what an end of line is, so PC and Linux/Mac text files won't be interchangeable. Which I kind of want for my new level file for #NthPongWars - the idea is that users can make their own levels by editing these text files. I ended up writing my own read a line at the current RetroNet file position function, with buffering, since it needs to work without CP/M or other OS support.