Angus Leeming <[EMAIL PROTECTED]> writes: | On Wednesday 11 September 2002 5:05 pm, Lars Gullik Bjønnes | wrote: | > | I'll make it easy for you. Here's the "bloody code". As you | > | can see there's a template parameter commT. | > | | > | commT can be | > | pipecomm_client | > | pipecomm_server | > | socketcomm_client | > | socketcomm_server | > | > Sure but this does not really solve the socket problem. | > | > | The point being that the bloody pipestream doesn't and | > | shouldn't care. The point also being that if we can get this | > | working with pipes, then getting it working with sockets is | > | simply a matter of writing the low level socketcomm class. | > | > This is not true, that is only true if you are planning to | > have only _one_ client connected to the socket. | > (or perhaps you are right... and what I descibe below _is_ the | > low-level socketcomm class you are talking about.) | > | > With sockets, you will have to run accept on the socket and | > you get a new socket each time somebody connects to it. All | > these sockes must then be registred in the io handeler system. | | Sorry I snapped. Will endeveaour to be polite. | | I think that your sockets are similar in this respect to my | "client" pipes. Multiple "clients" can connect to existing pipes | lyxpipe.in/out and communicate with lyx simultaneously.
As I showed with pipes... this is not possible. (it is a pipe dream to think so) | Basically, I think that pipestream is a high level class and the | actual communication is very low level (little more than | wrappers for ::open(), ::close(), ::read() and ::write()). It | /must/ be possible to hide the low level rubbish inside the | stream. Close but not quite. New connections (when speaking socket) must be handled with an accept. The fd returned from this accept can be passed to a socket_buf, and the rest can then be handled by your stream. (except that you now have to prepared to handle multiple streams at the same time.) | Anyway, my original problem still remains ;-) | | The pipestream works only if I add those last two lines: | | string const pipebase = "/home/aleem/.lyx/lyxpipe"; | Pipestream ps(pipebase.c_str()); | | vector<string> stuff_to_print; | vector<string>::const_iterator it = stuff_to_print.begin(); | vector<string>::const_iterator end = stuff_to_print.end(); | for (; it != end; ++it) { | // endl flushes the pipestream buffer | ps << *it << endl; | // for some reason this sets eof, so ... | if (ps.eof()) | ps.clear(); | } That clear resets some stream flags right (stream state). So if you have reached eof then the stream goes into a failure state, this failure state must be cleared if you want to receive anything else. (or write for that matter) -- Lgb