Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6104b5c
Add TCP handling for Server and Client
softins Jun 29, 2026
8e58ec6
Add some debug messages
softins Jun 30, 2026
d900ae3
Some fixes recommended by AI review
softins Jul 22, 2026
5aec70c
Use separate TCP sockets for IPv4 and IPv6
softins Jul 25, 2026
fbce28a
Add a channel token for use by server channels.
softins Jul 26, 2026
11851cd
Use channel token to authenticate a long TCP connection
softins Jul 26, 2026
156d2cd
Add operator!= for CHostAddress for completeness
softins Jul 27, 2026
b378a0c
Check that CLM_TCP_SUPPORTED for client ID comes from the connected s…
softins Jul 27, 2026
411831b
Only offer TCP mode if the listener started ok
softins Jul 27, 2026
a5f9e1b
Handle unlikely situation where new TCP connection replaces old
softins Jul 27, 2026
768d1f1
Log Error or EOF from TCP socket read
softins Jul 28, 2026
1c776fd
Update docs/TCP.md to include the channel token for TCP session authe…
softins Jul 28, 2026
63eefd9
Minor change to OnReadyRead()
softins Jul 28, 2026
0e577a4
Empty pending hashes when opening connect dialog
softins Jul 28, 2026
13a2a11
Minor updates from review
softins Jul 28, 2026
bf78aba
Do not log the channel token
softins Jul 28, 2026
e774d7c
Improvements from AI review
softins Jul 29, 2026
b7bf333
Change "TCP supported" to "TCP offered"
softins Aug 1, 2026
3f43aac
Updates to TCP.md
softins Aug 15, 2026
629e43d
Remove debug messages in preparation for production
softins Aug 15, 2026
bd2bdc1
Formatting fixes
softins Aug 24, 2026
16c8dcb
Make message ID available to CL sending functions
softins Sep 7, 2026
ab19fdc
Revert to UDP properly if TCP connection fails
softins Sep 7, 2026
6b737c2
Reset TCP session state in CClient::Stop()
softins Sep 8, 2026
6e97ff0
Add docs/TCP.md to DISTFILES
softins Sep 8, 2026
2010dc5
Improvements to docs/TCP.md after review
softins Sep 8, 2026
19f79ce
Remove unused CFM_UDP_RESULT from fetch modes
softins Sep 8, 2026
589ebf8
Remove noisy retry warnings
softins Sep 8, 2026
1e763a4
Reset fetch mode on aborted TCP connection
softins Sep 8, 2026
e87dcd6
Remove temporary debug messages
softins Sep 9, 2026
56c9631
Corrections to TCP.md following review
softins Sep 9, 2026
e8e4a10
In TCP.md, remove mention of large welcome message.
softins Sep 9, 2026
adc4ee3
Update TCP.md in response to review
softins Sep 9, 2026
c69a8e3
Revert "In TCP.md, remove mention of large welcome message."
softins Sep 10, 2026
ef101db
Add clarification about welcome text and split messages
softins Sep 10, 2026
520f19c
Remove unused signal CClient::CLTcpOfferedReceived
softins Sep 10, 2026
05aaf0a
Add clarification of potential welcome message size
softins Sep 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Jamulus.pro
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ HEADERS += src/plugins/audioreverb.h \
src/serverlogging.h \
src/settings.h \
src/socket.h \
src/tcpserver.h \
src/tcpconnection.h \
src/util.h \
src/recorder/jamrecorder.h \
src/recorder/creaperproject.h \
Expand Down Expand Up @@ -520,6 +522,8 @@ SOURCES += src/plugins/audioreverb.cpp \
src/settings.cpp \
src/signalhandler.cpp \
src/socket.cpp \
src/tcpserver.cpp \
src/tcpconnection.cpp \
src/util.cpp \
src/recorder/jamrecorder.cpp \
src/recorder/creaperproject.cpp \
Expand Down Expand Up @@ -725,6 +729,7 @@ DISTFILES += ChangeLog \
docs/JAMULUS_PROTOCOL.md \
docs/JSON-RPC.md \
docs/README.md \
docs/TCP.md \
docs/TRANSLATING.md \
linux/jamulus.desktop.in \
linux/jamulus-server.desktop.in \
Expand Down
222 changes: 222 additions & 0 deletions docs/TCP.md
Comment thread
pljones marked this conversation as resolved.

Large diffs are not rendered by default.

29 changes: 28 additions & 1 deletion src/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

// CChannel implementation *****************************************************
CChannel::CChannel ( const bool bNIsServer ) :
pTcpConnection ( nullptr ),
vecfGains ( MAX_NUM_CHANNELS, 1.0f ),
vecfPannings ( MAX_NUM_CHANNELS, 0.5f ),
iCurSockBufNumFrames ( INVALID_INDEX ),
Expand All @@ -59,6 +60,7 @@ CChannel::CChannel ( const bool bNIsServer ) :
bIsEnabled ( false ),
bIsServer ( bNIsServer ),
bIsIdentified ( false ),
iChannelToken ( 0 ),
iAudioFrameSizeSamples ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ),
SignalLevelMeter ( false, 0.5 ) // server mode with mono out and faster smoothing
{
Expand Down Expand Up @@ -103,7 +105,7 @@ CChannel::CChannel ( const bool bNIsServer ) :

QObject::connect ( &Protocol, &CProtocol::ChangeChanPan, this, &CChannel::OnChangeChanPan );

QObject::connect ( &Protocol, &CProtocol::ClientIDReceived, this, &CChannel::ClientIDReceived );
QObject::connect ( &Protocol, &CProtocol::ClientIDReceived, this, &CChannel::OnClientIDReceived );

QObject::connect ( &Protocol, &CProtocol::RawAudioSupported, this, &CChannel::RawAudioSupported );

Expand Down Expand Up @@ -764,3 +766,28 @@ void CChannel::UpdateSocketBufferSize()
SetSockBufNumFrames ( SockBuf.GetAutoSetting(), true );
}
}

void CChannel::OnClientIDReceived ( int iChanID ) { emit ClientIDReceived ( iChanID ); }

void CChannel::CreateConClientListMes ( const CVector<CChannelInfo>& vecChanInfo, CProtocol& ConnLessProtocol )
{
if ( pTcpConnection )
{
ConnLessProtocol.CreateCLConnClientsListMes ( InetAddr, vecChanInfo, pTcpConnection );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make clear why the connectionless protocol is used here - I suppose since TCP handles the session, it's enough.

Comment on lines +774 to +776
}
else
{
Protocol.CreateConClientListMes ( vecChanInfo );
}
}

void CChannel::SetTcpConnection ( CTcpConnection* pConnection )
{
if ( pTcpConnection )
{
// this should never happen, but handle it if it does
pTcpConnection->disconnectFromHost();
}

pTcpConnection = pConnection;
}
20 changes: 15 additions & 5 deletions src/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,15 @@ class CChannel : public QObject
void SetEnable ( const bool bNEnStat );
bool IsEnabled() { return bIsEnabled; }

void SetChannelToken ( const quint32 iNChannelToken ) { iChannelToken = iNChannelToken; }
quint32 GetChannelToken() { return iChannelToken; }

void SetAddress ( const CHostAddress& NAddr ) { InetAddr = NAddr; }
const CHostAddress& GetAddress() const { return InetAddr; }

void SetTcpConnection ( CTcpConnection* pConnection );
CTcpConnection* GetTcpConnection() { return pTcpConnection; }

void ResetInfo(); // reset does not emit a message
QString GetName();
void SetChanInfo ( const CChannelCoreInfo& NChanInf );
Expand Down Expand Up @@ -181,7 +187,7 @@ class CChannel : public QObject
void CreateReqChannelLevelListMes() { Protocol.CreateReqChannelLevelListMes(); }
//### TODO: END ###//

void CreateConClientListMes ( const CVector<CChannelInfo>& vecChanInfo ) { Protocol.CreateConClientListMes ( vecChanInfo ); }
void CreateConClientListMes ( const CVector<CChannelInfo>& vecChanInfo, CProtocol& ConnLessProtocol );

void CreateRecorderStateMes ( const ERecorderState eRecorderState ) { Protocol.CreateRecorderStateMes ( eRecorderState ); }

Expand All @@ -206,7 +212,8 @@ class CChannel : public QObject
}

// connection parameters
CHostAddress InetAddr;
CHostAddress InetAddr;
CTcpConnection* pTcpConnection;

// channel info
CChannelCoreInfo ChannelInfo;
Expand Down Expand Up @@ -237,6 +244,8 @@ class CChannel : public QObject
bool bIsServer;
std::atomic<bool> bIsIdentified;

quint32 iChannelToken;

int iNetwFrameSizeFact;
int iNetwFrameSize;
int iCeltNumCodedBytes;
Expand Down Expand Up @@ -275,11 +284,12 @@ public slots:
PutProtocolData ( iRecCounter, iRecID, vecbyMesBodyData, RecHostAddr );
}

void OnProtocolCLMessageReceived ( int iRecID, CVector<uint8_t> vecbyMesBodyData, CHostAddress RecHostAddr )
void OnProtocolCLMessageReceived ( int iRecID, CVector<uint8_t> vecbyMesBodyData, CHostAddress RecHostAddr, CTcpConnection* pTcpConnection )
{
emit DetectedCLMessage ( vecbyMesBodyData, iRecID, RecHostAddr );
emit DetectedCLMessage ( vecbyMesBodyData, iRecID, RecHostAddr, pTcpConnection );
}

void OnClientIDReceived ( int iChanID );
void OnNewConnection() { emit NewConnection(); }

signals:
Expand All @@ -303,7 +313,7 @@ public slots:
void RecorderStateReceived ( ERecorderState eRecorderState );
void Disconnected();

void DetectedCLMessage ( CVector<uint8_t> vecbyMesBodyData, int iRecID, CHostAddress RecHostAddr );
void DetectedCLMessage ( CVector<uint8_t> vecbyMesBodyData, int iRecID, CHostAddress RecHostAddr, CTcpConnection* pTcpConnection );

void ParseMessageBody ( CVector<uint8_t> vecbyMesBodyData, int iRecCounter, int iRecID );
};
Loading
Loading