I'm trying to convert a c program into c++ program . what is the equivalent header file for socket.h in c++ ?
With an uppercase 'S'? I don't think so.
anon
2010-07-06 16:42:31
@Neil: Yes; you're right.
SLaks
2010-07-06 16:44:00
A:
There's no real need to change the headers at all. On the other hand, if you're just planning to use the existing code, I'd probably just add:
#ifdef __cplusplus
#extern "C" {
#endif
and
#ifdef __cplusplus
}
#endif
...to a header for your existing code, and leave it as C instead of re-compiling as C++.
If you're developing new code in C++, I'd consider using something like POCO, ACE, or Boost::ASIO instead of writing directly to the sockets API.
Jerry Coffin
2010-07-06 16:51:23
All vaguely recent C/C++ implementations will do the test for __cplusplus for you - you would have to be using a really ancient compiler version to make these tests necessary in your own code.
anon
2010-07-06 17:14:31