![]() |
sponsored links |
|
|
sponsored links
|
|
1
23rd April 14:10
External User
Posts: 1
|
Since what you read from the pipe is an unstructured stream of bytes
there's probably nothing what you wouldn't call a "makeshift" solution. An alternative to your scheme would obvioulsy be to prepend each message with a fixed number of bytes telling the other side how long the message is going to be. If the number is e.g. 2 bytes you would first read these 2 bytes, so you know how many bytes to read in the second call of read(). All other methods would require some additional IPC, e.g. having the sender wait for a signal by the reader before sending another message, so the reader always knows there's no more than a single message in the pipe. Regards, Jens -- _ _____ _____ | ||_ _||_ _| Jens.Toerring@physik.fu-berlin.de _ | | | | | | | |_| | | | | | http://www.physik.fu-berlin.de/~toerring \___/ens|_|homs|_|oerring |
|
|
|
2
23rd April 14:10
External User
Posts: 1
|
There is a simple solution, if and only if what you are sending
is always just ascii text. Append a newline to the end of each block sent, thus making it line oriented. At the receiving end, use fdopen() on your socket to get a FILE*, and then use line oriented functions, like fgets() to retrieve data from the socket. -- Floyd L. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@barrow.com |
|