hello everyone,

I need help. i am trying out beejs guide to socket programming.
I get the following error while trying to compile my code.


Undefined first referenced
symbol in file
__xnet_socket /var/tmp//ccdwR3mW.o
listen /var/tmp//ccdwR3mW.o
inet_aton /var/tmp//ccdwR3mW.o
__xnet_bind /var/tmp//ccdwR3mW.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status


The code is given below


Code:
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <iostream>
using namespace std;

#define ServerIP "206.236.134.28"
#define MYPORT 3490    // the port users will be connecting to
#define BACKLOG 10     // how many pending connections queue will hold

int main()
{
    int sockfd, new_fd;  // listen on sock_fd, new connection on new_fd
    struct sockaddr_in my_addr;    // my address information
    struct sockaddr_in their_addr; // connector's address information
    int sin_size;

    sockfd = socket(PF_INET, SOCK_STREAM, 0); // do some error checking!

    my_addr.sin_family = AF_INET;         // host byte order
    my_addr.sin_port = htons(MYPORT);     // short, network byte order
    if(!inet_aton(ServerIP,&(my_addr.sin_addr)))
      cout<<"\nError: Unable to assigin address"<<endl;
    memset(&(my_addr.sin_zero), '\0', 8); // zero the rest of the struct

    // don't forget your error checking for these calls:
    bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr));

    listen(sockfd, BACKLOG);
   // sin_size = sizeof(struct sockaddr_in);
    //new_fd = accept(sockfd, (struct sockaddr *)&their_addr, (socklen_t*)&sin_size);
    //int recv(int new_fd, void *buf, int len, unsigned int flags);
    //cout<<"\nThe buffer = "<<buf<<" *buf "<<*buf;
    return 0;
}
Code:

i am comiling it as
#g++ <file name>