[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

Stream on Unix socket

pozz

3/25/2011 2:53:00 PM

I don't know if Unix sockets (or named sockets) are C standard. I
think so, so I post on this ng.

I need to have a bidirectional communication between two different
process on the same computer. I'm using named socket with success.

The protocol is on a text basis and is based on messages with an
ending newline character (\n).

Is it possible to have a stream pointer (FILE *) from the socket file
descriptor so I'll be able to use fprintf() and similar functions?
4 Answers

China Blue Veins

3/25/2011 3:03:00 PM

0

In article <635e290a-5b69-40fa-9ae3-b62d6686e0a8@h38g2000yqn.googlegroups.com>,
pozz <pozzugno@gmail.com> wrote:

> I don't know if Unix sockets (or named sockets) are C standard. I
> think so, so I post on this ng.
>
> I need to have a bidirectional communication between two different
> process on the same computer. I'm using named socket with success.
>
> The protocol is on a text basis and is based on messages with an
> ending newline character (\n).
>
> Is it possible to have a stream pointer (FILE *) from the socket file
> descriptor so I'll be able to use fprintf() and similar functions?

On Unix you can use fdopen to wrap an open file descriptor in a FILE*. You may
want to use setvbuf to control the bufferring.

--
Damn the living - It's a lovely life. I'm whoever you want me to be.
Silver silverware - Where is the love? At least I can stay in character.
Oval swimming pool - Where is the love? Annoying Usenet one post at a time.
Damn the living - It's a lovely life. Alameda County Sheriff.

Keith Thompson

3/25/2011 3:19:00 PM

0

pozz <pozzugno@gmail.com> writes:
> I don't know if Unix sockets (or named sockets) are C standard. I
> think so, so I post on this ng.

They aren't. Try comp.unix.programmer.

[...]

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.ne...
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Mark Bluemel

3/25/2011 3:48:00 PM

0

On 03/25/2011 02:53 PM, pozz wrote:
> I don't know if Unix sockets (or named sockets) are C standard. I
> think so, so I post on this ng.

No they're not.

<Off-topic>
If you want to work with them, I'd strongly recommend getting your
hands on a copy of <http://www.kohala.com/start/unpv12...
</Off-topic>

Bill Cunningham

3/27/2011 9:53:00 PM

0

Mark Bluemel wrote:
> On 03/25/2011 02:53 PM, pozz wrote:
>> I don't know if Unix sockets (or named sockets) are C standard. I
>> think so, so I post on this ng.
>
> No they're not.
>
> <Off-topic>
> If you want to work with them, I'd strongly recommend getting your
> hands on a copy of <http://www.kohala.com/start/unpv12...
> </Off-topic>

Great book. I've got it.

Bill