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
1ab9f05
Add TCP handling for Server and Client
softins Jun 29, 2026
2a72e5c
Add some debug messages
softins Jun 30, 2026
6c90dc7
Some fixes recommended by AI review
softins Jul 22, 2026
735a824
Use separate TCP sockets for IPv4 and IPv6
softins Jul 25, 2026
ad5757a
Add a channel token for use by server channels.
softins Jul 26, 2026
ac9765c
Use channel token to authenticate a long TCP connection
softins Jul 26, 2026
03ab070
Add operator!= for CHostAddress for completeness
softins Jul 27, 2026
f7296eb
Check that CLM_TCP_SUPPORTED for client ID comes from the connected s…
softins Jul 27, 2026
38b5d3d
Only offer TCP mode if the listener started ok
softins Jul 27, 2026
9bf4f60
Handle unlikely situation where new TCP connection replaces old
softins Jul 27, 2026
d065fac
Log Error or EOF from TCP socket read
softins Jul 28, 2026
6a41444
Update docs/TCP.md to include the channel token for TCP session authe…
softins Jul 28, 2026
f058473
Minor change to OnReadyRead()
softins Jul 28, 2026
4969fb5
Empty pending hashes when opening connect dialog
softins Jul 28, 2026
d1d9678
Minor updates from review
softins Jul 28, 2026
79a1e74
Do not log the channel token
softins Jul 28, 2026
752b02b
Improvements from AI review
softins Jul 29, 2026
f50c936
Change "TCP supported" to "TCP offered"
softins Aug 1, 2026
46713d5
Updates to TCP.md
softins Aug 15, 2026
dceb26d
Remove debug messages in preparation for production
softins Aug 15, 2026
f5f0e52
Formatting fixes
softins Aug 24, 2026
43e9491
Make message ID available to CL sending functions
softins Sep 7, 2026
bd0ea9d
Revert to UDP properly if TCP connection fails
softins Sep 7, 2026
4b6f9ae
Reset TCP session state in CClient::Stop()
softins Sep 8, 2026
ab7d8c8
Add docs/TCP.md to DISTFILES
softins Sep 8, 2026
c387154
Improvements to docs/TCP.md after review
softins Sep 8, 2026
95df900
Remove unused CFM_UDP_RESULT from fetch modes
softins Sep 8, 2026
506f6f5
Remove noisy retry warnings
softins Sep 8, 2026
d812338
Reset fetch mode on aborted TCP connection
softins Sep 8, 2026
c14cb92
Remove temporary debug messages
softins Sep 9, 2026
829bd81
Corrections to TCP.md following review
softins Sep 9, 2026
4376525
In TCP.md, remove mention of large welcome message.
softins Sep 9, 2026
72ac621
Update TCP.md in response to review
softins Sep 9, 2026
a2ad764
Revert "In TCP.md, remove mention of large welcome message."
softins Sep 10, 2026
732d01d
Add clarification about welcome text and split messages
softins Sep 10, 2026
cac4408
Remove unused signal CClient::CLTcpOfferedReceived
softins Sep 10, 2026
99c66a4
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 @@ -762,3 +764,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 +772 to +774
}
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