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/filename.h"
18 #include "support/socktools.h"
21 #include <boost/shared_ptr.hpp>
29 class LyXServerSocket;
33 /** Sockets can be in two states: listening and connected.
34 * Connected sockets are used to transfer data, and will therefore
35 * be called Data Sockets. Listening sockets are used to create
36 * Data Sockets when clients connect, and therefore will be called
39 * This class encapsulates local (unix) server socket operations and
40 * manages LyXDataSockets objects that are created when clients connect.
42 class LyXServerSocket {
45 LyXServerSocket(LyXFunc *, support::FileName const &);
48 /// Address of the local socket
49 std::string const address() const;
50 /// To be called when there is activity in the server socket
51 void serverCallback();
52 /// To be called when there is activity in the data socket
53 void dataCallback(int fd);
56 void writeln(std::string const &);
59 /// File descriptor for the server socket
61 /// Stores the socket filename
62 support::FileName address_;
63 /// Maximum number of simultaneous clients
68 std::map<int, boost::shared_ptr<LyXDataSocket> > clients;
72 /** This class encapsulates data socket operations.
73 * It provides read and write IO operations on the socket.
78 LyXDataSocket(int fd);
82 bool connected() const;
83 /// Line buffered input from the socket
84 bool readln(std::string &);
85 /// Write the string + '\n' to the socket
86 void writeln(std::string const &);
88 /// File descriptor for the data socket
90 /// True if the connection is up
92 /// buffer for input data
96 /// Implementation is in lyx_main.C
97 extern LyXServerSocket & theLyXServerSocket();
102 #endif // LYXSOCKET_H