By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,676 Members | 1,636 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,676 IT Pros & Developers. It's quick & easy.

Can someone explain these error codes Please.

P: 11
Hi,

I have constructed a client program that has given me some error codes that i just cannot see. I was wondering if a different set of eyes with much more experience than me could help me out. Here are the error codes and underneath i have listed the program. Thanks in advance for looking.

Expand|Select|Wrap|Line Numbers
  1. client.c: In function `main':
  2. client.c:118: error: syntax error before '-' token
  3. client.c: At top level:
  4. client.c:132: error: conflicting types for `close_socket'
  5. sockets.c.h:40: error: previous declaration of `close_socket'
  6. client.c:133: error: parse error before '}' token


Expand|Select|Wrap|Line Numbers
  1. /*client.c - demonstration client program. Written in C Nov '94 from
  2. Pascal version of Nov/Dec '93
  3. revised Oct 2005 to use stdio */
  4.  
  5. #include <stdio.h>
  6. #include "sockets.c.h"
  7.  
  8. main()
  9. {
  10.  
  11.    host_name       server;
  12.    port_number     port;
  13.    socket_id       local_socket;
  14.    int             ok,i,len;
  15.    socket_buffer   data;
  16.    char id[50];
  17.    char box[5];
  18.    char ack[50];
  19.    int boxlenerr;
  20.    char view_data[256];
  21.  
  22.    printf("client ...\n");
  23.    printf("please enter host server name\n");
  24.    scanf("%s",server);
  25.    printf("please enter server port number\n");
  26.    scanf("%d",&port);    /* remember the "&" to allow scanf to store the input value */
  27.  
  28.    local_socket = create_socket();
  29.    printf("client: socket %d created\n", local_socket);
  30.  
  31.    ok=connect_sockets(local_socket, server, port);
  32. /* socket is connected at this point */
  33.  
  34.    printf("Please enter your SetTopBox Number\t");
  35.    scanf("%s",box);
  36.  
  37.    if (strlen(box) !=10)
  38.      {
  39.        printf("Incorrect box number, please try again later\n");
  40.      }
  41.    else
  42.      {
  43.        send_data(local_socket,box,strlen(box)+1);
  44.        recv_data(local_socket,ack);
  45.      }
  46.  
  47.    printf("Please enter your Customer ID\t");
  48.    scanf("%s",id);
  49.  
  50. if (strlen(id) !=4)
  51.      {
  52.        printf("Your ID number needs to be 4 digits long\n");
  53.      }
  54.    else
  55.      {
  56.        send_data(local_socket,id,strlen(id)+1);
  57.        recv_data(local_socket,ack);
  58.      }
  59.  
  60.    int option;
  61.    option = 0;
  62.    printf("NuTV SELECTION MENU");
  63.    while (option !=4)
  64.      {
  65.         display_menu();
  66.        option = get_selection();
  67.        switch (option)
  68.          {
  69.              case 1: get_prog_ch();
  70.              break;
  71.              case 2 : get_prog_cat();
  72.              break;
  73.              case 3 : get_prog_sub();
  74.              break;
  75.          }
  76.      }
  77.    printf(" Thanks for calling Goodbye\n\n");
  78.  
  79.    if (ok < 0)
  80.    {
  81.       printf("failed to connect sockets\n");
  82.    }
  83.    else
  84.    {
  85.       printf("client: connection made to server, now use service\n");
  86.  
  87.       len=recv_data(local_socket,data);
  88.  
  89.       printf("client: %d bytes of data received\n",len);
  90.  
  91.       /* now display the data received, character by character */
  92.       for (i=0;i<len;i++)
  93.       {  printf("%c",data[i]);
  94.       }
  95.       printf("\n");
  96.    }
  97.  
  98. void display_menu()
  99.      {
  100.        printf("\n");
  101.        printf("Please choose an option\n");
  102.        printf("1-Choose programmes by channel number\n");
  103.        printf("2-Choose programmes by category\n");
  104.        printf("3-Choose programmes bt ctegory & sub-categroy\n");
  105.        printf("4- Exit the system\n");
  106.      }
  107.  
  108.    int get_selection()
  109.      {
  110.        int ch =0;
  111.        while (ch >3 && ch <1)
  112.          {printf("please enter your choice (1-3) and press return:\n");
  113.          scanf("%d",&ch);
  114. }
  115.        return (ch);
  116.      }
  117.  
  118.    void get_prog-ch()
  119.      {
  120.        printf(" this gets you the channels");
  121.      }
  122.  
  123.    void get_prog_cat()
  124.      {
  125.        printf(" By category");
  126.      }
  127.  
  128.    void get_prog_sub()
  129.      {
  130.        printf("By sub category");
  131.      }
  132.  
  133.  
  134. }
  135.  
  136.  
Apr 19 '07 #1
Share this Question
Share on Google+
4 Replies


Expert 10K+
P: 11,448
Check your curly brackets; I suspect you forgot one just before the display_menu
function. Other things might be wrong too; carefully read what your compiler has
to say about it.

kind regards,

Jos
Apr 19 '07 #2

P: 11
Ok have looked at them all and have found a couple of problems that i have since sorted. However now when i try to compile i get a new error message :

Expand|Select|Wrap|Line Numbers
  1. [r020032@jaguar sockets1]$ make
  2. gcc -w stream_sockets.o client.c -o client
  3. display_menu
  4. get_selection
  5. get_prog_ch
  6. get_prog_cat
  7. get_prog_sub
  8. collect2: ld returned 1 exit status
  9. *** Exit 1
  10. Stop.
Can you please explain what is going on here ?
Apr 19 '07 #3

P: 31
I was about to start a new thread, but I think this is the one i need.

I'm getting some conflicting types errors too, what does it mean?


./include/tipos.h:16: error: conflicting types for ‘packet’
./include/tipos.h:16: error: previous declaration of ‘packet’ was here
./include/tipos.h:27: error: conflicting types for ‘frame’
./include/tipos.h:27: error: previous declaration of ‘frame’ was here
./include/tipos.h:34: error: conflicting types for ‘arguments’
./include/tipos.h:34: error: previous declaration of ‘arguments’ was here
./include/tipos.h:36: error: conflicting types for ‘to_physical_layer’
./include/tipos.h:36: error: previous declaration of ‘to_physical_layer’ was here
./include/tipos.h:37: error: conflicting types for ‘from_physical_layer’
./include/tipos.h:37: error: previous declaration of ‘from_physical_layer’ was here
./include/tipos.h:38: error: conflicting types for ‘format_frame’
./include/tipos.h:38: error: previous declaration of ‘format_frame’ was here
May 31 '07 #4

blazedaces
100+
P: 284
I was about to start a new thread, but I think this is the one i need.

I'm getting some conflicting types errors too, what does it mean?


./include/tipos.h:16: error: conflicting types for ‘packet’
./include/tipos.h:16: error: previous declaration of ‘packet’ was here
./include/tipos.h:27: error: conflicting types for ‘frame’
./include/tipos.h:27: error: previous declaration of ‘frame’ was here
./include/tipos.h:34: error: conflicting types for ‘arguments’
./include/tipos.h:34: error: previous declaration of ‘arguments’ was here
./include/tipos.h:36: error: conflicting types for ‘to_physical_layer’
./include/tipos.h:36: error: previous declaration of ‘to_physical_layer’ was here
./include/tipos.h:37: error: conflicting types for ‘from_physical_layer’
./include/tipos.h:37: error: previous declaration of ‘from_physical_layer’ was here
./include/tipos.h:38: error: conflicting types for ‘format_frame’
./include/tipos.h:38: error: previous declaration of ‘format_frame’ was here
Start a new thread about this... post your code as well, it would help in figuring out what is indeed the problem.

-blazed
May 31 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.