468,720 Members | 1,732 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,720 developers. It's quick & easy.

write function ?

Hi,
I'm trying to understand a small cpp program which uses a function called
write.
An example of a line using this function is
write (hsocket,strclose,strlen(strclose)); where strclose is a string to
write, and hsocket is a int containing a socket handle.
The cpp program headers are
#include <iostream>
#include <string.h>
#include <sys/stat.h>
using namespace std;
and an included netfunc.h containing prototypes for various c sockets
functions in a netfunc.c program (but NOT write).

This write function must be the sockets write function ? But how does this
function compile correctly in this case ? It's a c function in a cpp file ?
Thanks
Tony
Feb 6 '07 #1
1 3238
Tony B wrote:
Hi,
I'm trying to understand a small cpp program which uses a function called
write.
An example of a line using this function is
write (hsocket,strclose,strlen(strclose)); where strclose is a string to
write, and hsocket is a int containing a socket handle.
The cpp program headers are
#include <iostream>
#include <string.h>
#include <sys/stat.h>
using namespace std;
and an included netfunc.h containing prototypes for various c sockets
functions in a netfunc.c program (but NOT write).

This write function must be the sockets write function ? But how does this
function compile correctly in this case ? It's a c function in a cpp file ?
Thanks
Tony

Likely it is just luck. On my system <iostreameventually include
<unistd.h>, which is where write is declared. Of course, the C++
standard doesn't guarantee that (write isn't part of the standard C++
library), and I very seriously doubt POSIX makes any such guarantee either.

--
Alan Johnson
Feb 6 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Bob Murdoch | last post: by
9 posts views Thread by James Marshall | last post: by
2 posts views Thread by Geoff Wilkins | last post: by
2 posts views Thread by Eric Mitchell | last post: by
2 posts views Thread by bissatch | last post: by
18 posts views Thread by jacob navia | last post: by
88 posts views Thread by Peter Olcott | last post: by
1 post views Thread by Oskars | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.