#include "DispatchResult.h"
#include "FuncRequest.h"
-#include "LyX.h"
#include "LyXAction.h"
#include "frontends/Application.h"
#include "support/debug.h"
#include "support/environment.h"
#include "support/FileName.h"
+#include "support/lassert.h"
#include "support/socktools.h"
-#include "support/bind.h"
+#include <boost/assert.hpp>
#include <cerrno>
+#include <cstring>
#include <ostream>
#if defined (_WIN32)
# include <io.h>
#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
using namespace std;
using namespace lyx::support;
-
namespace lyx {
// Address is the unix address for the socket.
// is OK and if the number of clients does not exceed MAX_CLIENTS
void ServerSocket::serverCallback()
{
+ if (clients.size() >= MAX_CLIENTS) {
+ writeln("BYE:Too many clients connected");
+ return;
+ }
+
int const client_fd = socktools::accept(fd_);
if (fd_ == -1) {
return;
}
- if (clients.size() >= MAX_CLIENTS) {
- writeln("BYE:Too many clients connected");
- return;
- }
-
// Register the new client.
- clients[client_fd] =
- shared_ptr<LyXDataSocket>(new LyXDataSocket(client_fd));
+ clients[client_fd] = make_shared<LyXDataSocket>(client_fd);
theApp()->registerSocketCallback(
client_fd,
bind(&ServerSocket::dataCallback,
return;
shared_ptr<LyXDataSocket> client = it->second;
string line;
- size_t pos;
bool saidbye = false;
while (!saidbye && client->readln(line)) {
// The protocol must be programmed here
// Split the key and the data
+ size_t pos;
if ((pos = line.find(':')) == string::npos) {
client->writeln("ERROR:" + line + ":malformed message");
continue;