Skip to content

Commit

Permalink
* fine tuned TCP_NODELAY && TCP_CORK
Browse files Browse the repository at this point in the history
* scores can get retrieved from within running game as well
  • Loading branch information
velnias75 committed Aug 18, 2015
1 parent 6a23076 commit 1421152
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/client/abstractclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#endif

#include "base64.h"
#include "tcpopt_cork.h"
#include "tcpopt_nodelay.h"
#include "abstractclientv05impl.h" // for AbstractClientV05Impl
#include "logger.h" // for BasicLogger, logDebug
Expand Down Expand Up @@ -271,10 +272,14 @@ throw(NetMauMau::Common::Exception::SocketException) {
void AbstractClientV05::play(timeval *timeout)
throw(NetMauMau::Common::Exception::SocketException) {

TCPOPT_NODELAY(_pimpl->m_connection.getSocketFD());
{
TCPOPT_CORK(_pimpl->m_connection.getSocketFD());

_pimpl->m_connection.setTimeout(timeout);
_pimpl->m_connection.connect(this, _pimpl->m_pngData.data(), _pimpl->m_pngData.size());
_pimpl->m_connection.setTimeout(timeout);
_pimpl->m_connection.connect(this, _pimpl->m_pngData.data(), _pimpl->m_pngData.size());
}

TCPOPT_NODELAY(_pimpl->m_connection.getSocketFD());

AbstractClientV05Impl::PNGDATA().swap(_pimpl->m_pngData);

Expand Down Expand Up @@ -822,9 +827,6 @@ throw(NetMauMau::Common::Exception::SocketException) {

AbstractClientV09::SCORES AbstractClientV09::getScores(SCORE_TYPE::_scoreType type,
std::size_t limit, timeval *timeout) throw(NetMauMau::Common::Exception::SocketException) {

if(_pimpl->m_playing) throw Exception::ScoresException("Attempt to get scores in running game");

_pimpl->m_connection.setTimeout(timeout);
return _pimpl->m_connection.getScores(type, limit);
}
Expand Down
5 changes: 3 additions & 2 deletions src/client/clientconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Connection::PLAYERINFOS Connection::playerList(const IPlayerPicListener *hdl, bo
throw(NetMauMau::Common::Exception::SocketException) {

BLOCK_MOST_SIGNALS;
TCPOPT_CORK(getSocketFD());

PLAYERINFOS plv;

Expand Down Expand Up @@ -184,7 +185,7 @@ Connection::CAPABILITIES Connection::capabilities()
throw(NetMauMau::Common::Exception::SocketException) {

BLOCK_ALL_SIGNALS;
TCPOPT_NODELAY(getSocketFD());
TCPOPT_CORK(getSocketFD());

Connection::CAPABILITIES caps;

Expand Down Expand Up @@ -218,7 +219,7 @@ Connection::SCORES Connection::getScores(SCORE_TYPE::_scoreType type, std::size_
throw(NetMauMau::Common::Exception::SocketException) {

BLOCK_ALL_SIGNALS;
TCPOPT_NODELAY(getSocketFD());
TCPOPT_CORK(getSocketFD());

try {

Expand Down

0 comments on commit 1421152

Please sign in to comment.