permission denied error in socket programming in c

Hi everyone,I got error when I run this program. I am using ubuntu 11.10.
This is my program.

#include "socket.h"


using namespace Robot;



//int fileSEND(const char *server, int PORT, const char *lfile, const char *rfile)
//{
int main (int argc, char *argv[])
{
int socketDESC;
struct sockaddr_in serverADDRESS;
struct hostent *hostINFO;
/*FILE *file_to_send;
int ch;
char toSEND[1];
char remoteFILE[4096];
int count1=1, count2=1, percent;
char buffer[4096];*/

int PORT;
Image *send_img;
int length =4096;

hostINFO = gethostbyname(argv[1]);

if(hostINFO==NULL)
{
printf("Problem interpreting host\n");
return 1;
}
PORT = atoi(argv[2]);
socketDESC = socket(AF_INET, SOCK_STREAM, 0);
if(socketDESC<0)
{
printf("Cannot create socket\n");
return 1;
}

serverADDRESS.sin_family = hostINFO->h_addrtype;
memcpy((char *) &serverADDRESS.sin_addr.s_addr, hostINFO->h_addr_list[0],hostINFO->h_length);
serverADDRESS.sin_port = htons(PORT);

if(connect(socketDESC,(struct sockaddr *)&serverADDRESS,sizeof(serverADDRESS))<0)
{
printf("Cannot connect\n");
return 1;
}

while(1)
{
LinuxCamera::GetInstance()->CaptureFrame();

send_img=LinuxCamera::GetInstance()->fbuffer->m_RGBFrame;
send(socketDESC,send_img, length,0);
}
close(socketDESC);
return 0;
}

after i run, I got "permission denied"
Why is that so? If anyone knows how tosolve it, pls kindly share me. thanks
Topic archived. No new replies allowed.