Read from socket
Posted
by Alberto
on Stack Overflow
See other posts from Stack Overflow
or by Alberto
Published on 2010-06-16T13:41:19Z
Indexed on
2010/06/16
13:52 UTC
Read the original article
Hit count: 141
I need to read from an AF_UNIX socket to a buffer using the function read
from C, but I don't know the buffer size.
I think the best way is to read N
bytes until the read returns 0
(no more writers in the socket). Is this correct? Is there a way to guess the size of the buffer being written on the socket?
I was thinking that a socket is a special file. Opening the file in binary mode and getting the size would help me in knowing the correct size to give to the buffer?
I'm a very new to C, so please keep that in mind.
© Stack Overflow or respective owner