2

I want to know is there any API/system call which i can use to just read the input stream without removing the data read from input stream?

I am looking for something like peek() function of arduino. I want to use it for some socket programming (RAW HCI socket).

abhiarora
  • 9,743
  • 5
  • 32
  • 57
  • 1
    Well, you could cook up a solution around this http://stackoverflow.com/questions/2082743/c-equivalent-to-fstreams-peek/2082772#2082772 – StoryTeller - Unslander Monica Feb 23 '17 at 11:32
  • 1
    Maybe `tee(2)` is what you are looking for. – Ctx Feb 23 '17 at 11:40
  • @StoryTeller I am using raw file descriptors in Linux. Can a convert a raw fd into `FILE *`? – abhiarora Feb 23 '17 at 11:47
  • 3
    @abhiarora a call to `fdopen(3)` can wrap a raw filedescriptor to a `FILE *`, but if the behaviour of the resulting stream will fit your needs depends on your application (i.e. when the fd is shared between different processes) – Ctx Feb 23 '17 at 11:50
  • @Ctx Thanks for the answer. It is similar to what i was looking – abhiarora Feb 23 '17 at 12:35

0 Answers0