Hi,
we are developing protocol for vxworks.
This protocol writing data in socket onwhich client application reads the data.
application runs on linux machine.
Client application reads the data in the loop.
Protocol writes the entire data in the write call.
Client application reads the data. It is fine.
In the loop(in application), we are checking "count > 0".
while( (count = read(fd, buffer, sizeof(buffer)-1)) > 0 )
{
// some code
}
MY QUESTION :
In the protocol,How to indicate the EOF, while writing data into the socket?
ie. In the client application, how to terminate the read to come out of the loop?
read function description says that it is expecting EOF for count becomes zero.
Thanks,
Raphel
|
|
0
|
|
|
|
Reply
|
rapheli78
|
1/28/2004 10:52:25 AM |
|
rapheli78@hotmail.com (Raphel) writes:
> Hi,
>
> we are developing protocol for vxworks. This protocol writing data
> in socket onwhich client application reads the data. application
> runs on linux machine.
>
> Client application reads the data in the loop.
> Protocol writes the entire data in the write call.
> Client application reads the data. It is fine.
> In the loop(in application), we are checking "count > 0".
>
> while( (count = read(fd, buffer, sizeof(buffer)-1)) > 0 )
> {
> // some code
> }
>
> MY QUESTION : In the protocol,How to indicate the EOF, while writing
> data into the socket? ie. In the client application, how to
> terminate the read to come out of the loop?
>
> read function description says that it is expecting EOF for count
> becomes zero.
Close the socket.
--
M�ns Rullg�rd
mru@kth.se
|
|
0
|
|
|
|
Reply
|
mru
|
1/28/2004 10:58:57 AM
|
|
294474405
Hello, "Raphel" <rapheli78@hotmail.com>
> we are developing protocol for vxworks.
> This protocol writing data in socket onwhich client application reads the
data.
> application runs on linux machine.
>
> Client application reads the data in the loop.
> Protocol writes the entire data in the write call.
> Client application reads the data. It is fine.
> In the loop(in application), we are checking "count > 0".
>
> while( (count = read(fd, buffer, sizeof(buffer)-1)) > 0 )
> {
> // some code
> }
>
> MY QUESTION :
> In the protocol,How to indicate the EOF, while writing data into the
socket?
> ie. In the client application, how to terminate the read to come out of
the loop?
>
> read function description says that it is expecting EOF for count becomes
zero.
if i understand you right, you just need close socket on protocol side.
--
chris
|
|
1
|
|
|
|
Reply
|
Alexander
|
1/28/2004 11:02:05 AM
|
|
Well, that depends on the protocol.
UDP: write() writes one packet, read() reads it
TCP: write() writes part of a stream, read() reads some bytes from the
stream up to the maximum count you specify. You need something at the
application level to split the stream into chunks of data, e.g. a byte
count preceding every chunk. Unless you mean how do you know when the
client has closed the TCP connection, in which case read() will return 0.
Robert
Raphel wrote:
> Hi,
>
> we are developing protocol for vxworks.
> This protocol writing data in socket onwhich client application reads the data.
> application runs on linux machine.
>
> Client application reads the data in the loop.
> Protocol writes the entire data in the write call.
> Client application reads the data. It is fine.
> In the loop(in application), we are checking "count > 0".
>
> while( (count = read(fd, buffer, sizeof(buffer)-1)) > 0 )
> {
> // some code
> }
>
> MY QUESTION :
> In the protocol,How to indicate the EOF, while writing data into the socket?
> ie. In the client application, how to terminate the read to come out of the loop?
>
> read function description says that it is expecting EOF for count becomes zero.
>
> Thanks,
> Raphel
|
|
-1
|
|
|
|
Reply
|
Robert
|
1/28/2004 11:09:15 AM
|
|
|
3 Replies
1151 Views
(page loaded in 0.074 seconds)
|