Hi:
I had a question on how to use:
int Read(char *buffer, int size, OpenFileId id);
void Write(char *buffer, int size, OpenFileId id);

This is for a client that is connected to a network host server and it is for a chatting program. If someone could direct me to a site with good examples, I would appreciate that. Every site I have looked up only tells me what it does and what the parameters are, but they are very brief, and summed up explanations. I was hoping I could look at some examples or something that would tell me in detail what each argument is and how I can relate it to the variables I possess. Thanks.

int Read(char *buffer, int size, OpenFileId id);
void Write(char *buffer, int size, OpenFileId id);

buffer is the string containing data you want to read or write. size is the length of that buffer (probably strlen(buffer)+1). id is the file id.

I'm just guessing here. :)

This looks like MS code.

If that's the case try www.msdn.microsoft.com


OpenFileId is a file handle created by open.
int is the size of the buffer you want to read
buf is the address of the buffer

Read returns (-1 or possibly zero) for a variety of reasons, including being pre-empted (interrupted by another higher priority process). I don't recall the value Windows sets errno to. POSIX standard is EINTR - but Windows doesn't follow any standards.

You MUST check errno if you get an EOF or a zero back from read to determine what to do.

This article has been dead for over six months. Start a new discussion instead.