Socket programming in C++ in Ubuntu
<p>I have tried to implement a program using sockets in Ubuntu 10.04. Here is the code:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;sys/types.h&gt;
#include&lt;netinet/in.h&gt;
#include &lt;sys/socket.h&gt;
#include &lt;netdb.h&gt;
#include &lt;unistd.h&gt;
#include &lt;errno.h&gt;
#include &lt;exception&gt;
using namespace std;
using std::exception;
int main(int argc,char *argv[]){
    int sockethandle;
    if ((sockethandle=socket(AF_INET,SOCK_STREAM,IPPROTO_IP))&lt;0)
    {
        close(sockethandle);
        exit(EXIT_FAILURE);
    }
    return 0;
}
</code></pre>

<p>But here are the compile errors:</p>

<pre><code>usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/david/NetBeansProjects/socket'
/usr/bin/make  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/socket
make[2]: Entering directory `/home/david/NetBeansProjects/socket'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++    -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
main.cpp: In function ‘int main()’:
main.cpp:18: error: ‘EXIT_FAILURE’ was not declared in this scope
main.cpp:18: error: ‘exit’ was not declared in this scope
make[2]: *** [build/Debug/GNU-Linux-x86/main.o] Error 1
make[2]: Leaving directory `/home/david/NetBeansProjects/socket'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/david/NetBeansProjects/socket'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 929ms)
</code></pre>

<p>How can this be fixed?</p>
