Re: std::cin and disabling canonical line processing (buffering)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks!

I believe I have found a couple of implementations of sockets in streams but
I haven't tried them. I expect that I will be using them strictly as I/O and
not doing any fancy control.

"Jason Winnebeck" wrote:

> There do exist streambuf implementations for the various sockets, and
> even if I am wrong I would figure it would be pretty easy to write one.
> I can't think of any "gotchas" or other problems if you could do:
> * setup the socket
> * create the streambufs, istream, and ostream around that socket
> * call the function
> * close the sockets
>
> The problem with socket-in-a-streambuf is that it is not possible to
> call socket functions and such on it, but if you only need the stream
> temporarily as an "interface" of sorts, then you can do all of the
> socket stuff in the calling function.
>
> Jason
>
> Harold Bamford wrote:
> > That's the typical case, isn't it? But not here.
> >
> > I have a program that runs a command line interface on an embedded system.
> > The user can access this via telnet or via an RS232 port that the system will
> > treat as a console. In the embedded system, a task is spawned and the task
> > function is just given the stream pointers. Unfortunately, I don't have much
> > of a say on whether I can get a flag saying "isConsole". After all, as
> > EVERYONE knows, a stream is a stream is a stream...
> >
> > Obviously, if the stream pointers refer to a socket, there won't be
> > console-like stuff to deal with. But if the pointers are for the RS232 (aka,
> > console), then I do have to deal.
> >
> > I also want to have this same CLI run under Windows where it will always be
> > accessed from an actual console. Except that someday, this may actually run
> > in a server process and be accessed through sockets, thus putting me in the
> > same position as with the embedded system.
> >
> > The trick is to limit the system dependencies to a small area. As a first
> > crack, I can #ifdef on WIN32 and just assume I've got cin, but I want to be
> > prepared for the next step...
> >
> > Thanks for your help.
> >
> > -- Harold
> >
> >
> > "Jason Winnebeck" wrote:
> >
> >
> >>Are you trying to make a smart application like grep where it works
> >>differently if it gets its input from standard input (as in from a pipe)
> >>or from a file, as in:
> >>
> >>prog | YourCommand
> >>versus
> >>YourCommand SomeFile
> >>
> >>If so, you might be able to infer the information you need. Make the
> >>function take a boolean "isConsole" If the user passed a filename, then
> >>you pass false and a reference to istream that reads the file, if the
> >>user did not you pass an argument, you pass true for isConsole and pass
> >>a reference to cin.
> >>
> >>This is just an idea; I don't know how well it would work in practice,
> >>or if this is what you are looking for.
> >>
> >>Jason
> >>
> >>Harold Bamford wrote:
> >>
> >>>Now, how do I tell if it is a pointer to console input? Is there a way to
> >>>get the handle associated with an istream? I suspect the just comparing
> >>>addresses won't be reliable. Should I compare addresses of some internal
> >>>structure?
> >>
>
.



Relevant Pages

  • Re: std::cin and disabling canonical line processing (buffering)
    ... create the streambufs, istream, and ostream around that socket ... The problem with socket-in-a-streambuf is that it is not possible to call socket functions and such on it, but if you only need the stream temporarily as an "interface" of sorts, then you can do all of the socket stuff in the calling function. ... The user can access this via telnet or via an RS232 port that the system will treat as a console. ... In the embedded system, a task is spawned and the task function is just given the stream pointers. ...
    (microsoft.public.vc.stl)
  • Re: How do I stop a Winsock from buffering characters?
    ... it's applied at the OS level to the socket. ... Stream s = client.GetStream; ... from the client code and have the server see it right away. ... first character of the client send. ...
    (microsoft.public.windowsce.embedded)
  • Concurrent reader/writer threads on single socket
    ... I have what I imagine is a well-known .Net networking problem, ... one dedicated to reading from the socket and the other one ... BinaryWriter writer = new BinaryWriter); ... the output stream would hold a separate buffer ...
    (microsoft.public.dotnet.general)
  • socket bug or not?
    ... This works fine, I at some point wrote a webservice to send msgs to my system, not using any twisted code, that sends a message to ... I discovered that it was because my webservice did not read the "<stream>" element sent by the server when it connected, when I added the code to read it, everything worked as expected. ... I tested the webservice to without the server to see if it had a problem, using netcat, and it does, so I wonder if there is a bug in the socket code or not. ...
    (comp.lang.python)
  • Re: Im having problems with cryptography and sockets, help
    ... If the sender does not send 8192 bytes, the call to Read is going to ... I am> using blocking sockets, so I am aware that if the socket does not have ... But I know that it does receive> the data, and still it blocks, not the NetworkStream, but the CryptoStream> used to decrypt the data. ... > NetworkStream stream = clienteTcp.GetStream;> // Crear el stream criptográfico ...
    (microsoft.public.dotnet.languages.csharp)