tags:

views:

36

answers:

2

I'm trying to convert a c program into c++ program . what is the equivalent header file for socket.h in c++ ?

A: 

socket.h

SLaks
With an uppercase 'S'? I don't think so.
anon
@Neil: Yes; you're right.
SLaks
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
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