4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
9 * \author João Luis M. Assirati
11 * Full author contact details are available in file CREDITS.
17 #include "support/socktools.h"
20 #include <boost/shared_ptr.hpp>
28 class LyXServerSocket;
32 /** Sockets can be in two states: listening and connected.
33 * Connected sockets are used to transfer data, and will therefore
34 * be called Data Sockets. Listening sockets are used to create
35 * Data Sockets when clients connect, and therefore will be called
38 * This class encapsulates local (unix) server socket operations and
39 * manages LyXDataSockets objects that are created when clients connect.
41 class LyXServerSocket {
44 LyXServerSocket(LyXFunc *, std::string const &);
47 /// Address of the local socket
48 std::string const & address() const;
49 /// To be called when there is activity in the server socket
50 void serverCallback();
51 /// To be called when there is activity in the data socket
52 void dataCallback(int fd);
55 void writeln(std::string const &);
58 /// File descriptor for the server socket
60 /// Stores the socket filename
62 /// Maximum number of simultaneous clients
67 std::map<int, boost::shared_ptr<LyXDataSocket> > clients;
71 /** This class encapsulates data socket operations.
72 * It provides read and write IO operations on the socket.
77 LyXDataSocket(int fd);
81 bool connected() const;
82 /// Line buffered input from the socket
83 bool readln(std::string &);
84 /// Write the string + '\n' to the socket
85 void writeln(std::string const &);
87 /// File descriptor for the data socket
89 /// True if the connection is up
91 /// buffer for input data
95 /// Implementation is in lyx_main.C
96 extern LyXServerSocket & theLyXServerSocket();
101 #endif // LYXSOCKET_H