472,334 Members | 1,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,334 software developers and data experts.

Can someone explain these error codes Please.

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
4 2202
JosAH
11,448 Expert 8TB
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
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
Sieira
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
284 100+
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

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

Similar topics

5
by: Mark Oueis | last post by:
I've been struggling with this question for a while. What is better design? To design functions to return error codes when an error occures, or to...
8
by: Shane Groff | last post by:
I know this is a recurring discussion (I've spent the last 3 days reading through threads on the topic), but I feel compelled to start it up again....
2
by: Daniel O'Connell [C# MVP] | last post by:
Does anyone know of a list of csc error codes other than the one in the MSDN documentation. Hunting through one codes per topic is a little...
0
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and...
1
by: Tran Hong Quang | last post by:
Hi, In header file, I see this declaration: #define DECLARE_VTBL(iname) iname vt##iname; then, in C file, there are below codes: ...
8
by: PW | last post by:
Hi, There is code in Alison Balter's excellant "Mastering Access 2003" to create a list of error codes and descriptions but it only generates...
13
by: mike3 | last post by:
Hi. (crossposted because the program is in C++ and some C++-related elements are discussed, hence comp.lang.c++, plus general program design...
1
by: pallavi814 | last post by:
Hi , When i search for the DB2 error codes,some of the DB2 error codes donot list the sql code. For example,"SQL0004N - The password is not valid...
5
by: =?GB2312?B?17/HvyBaaHVvLCBRaWFuZw==?= | last post by:
Hi, I would like to have someone comments on what's the best practice defining error codes in C. Here's what I think: solution A: using enum...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.