954,206 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

help with some error codes please.

Hi all,

Am fairly new to the programming world, but am kind of struggling along. I have written a piece of code for a client program with has given me some errors that i just can't see when compiling. The errors listed are :

client.c: In function `main':
  client.c:118: error: syntax error before '-' token
  client.c: At top level:
  client.c:132: error: conflicting types for `close_socket'
  sockets.c.h:40: error: previous declaration of `close_socket'
  client.c:133: error: parse error before '}' token


And i have also listed the program below. I hope that someone can point out the errors in my ways. Thanks in advance for looking.

;
     char box[5];
     char ack[50];
     int boxlenerr;
     char view_data[256];
   
     printf("client ...\n");
     printf("please enter host server name\n");
     scanf("%s",server);
     printf("please enter server port number\n");
     scanf("%d",&port);    /* remember the "&" to allow scanf to store the input value */
   
     local_socket = create_socket();
     printf("client: socket %d created\n", local_socket);
   
     ok=connect_sockets(local_socket, server, port);
  /* socket is connected at this point */
   
     printf("Please enter your SetTopBox Number\t");
     scanf("%s",box);
   
     if (strlen(box) !=10)
       {
         printf("Incorrect box number, please try again later\n");
       }
     else
       {
         send_data(local_socket,box,strlen(box)+1);
         recv_data(local_socket,ack);
       }
   
     printf("Please enter your Customer ID\t");
     scanf("%s",id);
   
  if (strlen(id) !=4)
       {
         printf("Your ID number needs to be 4 digits long\n");
       }
     else
       {
         send_data(local_socket,id,strlen(id)+1);
         recv_data(local_socket,ack);
       }
   
     int option;
     option = 0;
     printf("NuTV SELECTION MENU");
     while (option !=4)
       {
          display_menu();
         option = get_selection();
         switch (option)
           {
               case 1: get_prog_ch();
               break;
               case 2 : get_prog_cat();
               break;
               case 3 : get_prog_sub();
               break;
           }
       }
     printf(" Thanks for calling Goodbye\n\n");
   
     if (ok < 0)
     {
        printf("failed to connect sockets\n");
     }
     else
     {
        printf("client: connection made to server, now use service\n");
   
        len=recv_data(local_socket,data);
   
        printf("client: %d bytes of data received\n",len);
   
        /* now display the data received, character by character */
        for (i=0;i<len;i++)
        {  printf("%c",data[i]);
        }
        printf("\n");
     }
   
  void display_menu()
       {
         printf("\n");
         printf("Please choose an option\n");
         printf("1-Choose programmes by channel number\n");
         printf("2-Choose programmes by category\n");
         printf("3-Choose programmes bt ctegory & sub-categroy\n");
         printf("4- Exit the system\n");
       }
   
     int get_selection()
       {
         int ch =0;
         while (ch >3 && ch <1)
           {printf("please enter your choice (1-3) and press return:\n");
           scanf("%d",&ch);
  }
         return (ch);
       }
   
     void get_prog-ch()
       {
         printf(" this gets you the channels");
       }
   
     void get_prog_cat()
       {
         printf(" By category");
       }
   
     void get_prog_sub()
       {
         printf("By sub category");
       }
     
     
  }
fatboysudsy
Newbie Poster
11 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

The problem is mis-matched braces '{' and '}'. delete line 119.

what is the semicolon doing on line 1?

Ancient Dragon
Retired & Loving It
Team Colleague
30,046 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342
 

hi,

Thanks have done that, think that the ; is a typo error. Now when i compile i get :


gcc -w stream_sockets.o client.c -o client
display_menu
get_selection
get_prog_ch
get_prog_cat
get_prog_sub
collect2: ld returned 1 exit status
*** Exit 1
Stop.

what is going on here ?

fatboysudsy
Newbie Poster
11 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

I would guess you call the ld system command from somewhere in your program and it returned with an error. But it's only a guess since there's no code posted to verify it.

WaltP
Posting Sage w/ dash of thyme
Moderator
10,492 posts since May 2006
Reputation Points: 3,348
Solved Threads: 943
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You