Like Tree1Likes
  • 1 Post By stahta01

compilation error

This is a discussion on compilation error within the Networking/Device Communication forums, part of the General Programming Boards category; Im not worried about the warnings or notes. What I would like to know is what would cause this kind ...

  1. #1
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302

    (SOLVED)compilation error

    Im not worried about the warnings or notes. What I would like to know is what would cause this kind of fatal error? Line number 48 it says.

    Code:
    ubuntu@ubuntu:~/Documents$ gcc server.c -o server
    server.c: In function ‘main’:
    server.c:38: warning: passing argument 3 of ‘accept’ makes pointer from integer without a cast
    /usr/include/sys/socket.h:214: note: expected ‘socklen_t * __restrict__’ but argument is of type ‘unsigned int’
    server.c: At top level:
    server.c:48: fatal error: error closing /tmp/ccE99bS8.s: No space left on device
    compilation terminated.
    ubuntu@ubuntu:~/Documents$
    I have been coding a basic server twice a day for 2 weeks and have never had a problem till now for some odd reason. but heres the code just in case

    Code:
    /*A simple TCP server for linux*/
    #include <string.h>
    #include <stdio.h>
    #include <unistd.h>
    #include <sys/socket.h>
    #include <sys/types.h>
    #include <netinet/in.h>
    #include <netdb.h>
    
    int main(int argc, char *argv[]) {
    int sockfd, newsockfd, portno;
    char buffer[256]; 
    struct sockaddr_in serv_addr, cli_addr;
    
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if(sockfd < 0) fprintf(stderr, "Error creating socket.");
    
    bzero((char *) &serv_addr, sizeof(serv_addr));
    portno = atoi(argv[1]);
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = INADDR_ANY;
    serv_addr.sin_port = htons(portno);
    
    if(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) 
    fprintf(stderr, "Error binding to socket.");
    
    listen(sockfd, 5); 
    
    newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, sizeof(cli_addr));
    if(newsockfd < 0) fprintf(stderr, "Error accepting new connection.");
    
    for( ; ; ) {
    
    }
    
    close(newsockfd);
    close(sockfd);
    return 0;
    }
    Last edited by Annonymous; 06-22-2011 at 10:58 PM. Reason: problem solved

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    2,915
    Argument 3 of accept() should be a socklen_t * you are trying to pass an integer.

    Jim

  3. #3
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    @Jimblumberg, that fixed it. I didn't think that would cause a fatal error. Thanks

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    2,915
    Don't forget to fix these warnings:
    main.c||In function ‘main’:|
    main.c|18|warning: implicit declaration of function ‘bzero’
    main.c|19|warning: implicit declaration of function ‘atoi’|
    Jim

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    > server.c:48: fatal error: error closing /tmp/ccE99bS8.s: No space left on device
    This means the compiler aborted because your /tmp is FULL
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    Yeah I noticed that yesterday Salem. I looked in my tmp folder and everything I was saving in my documents, was also saving in my tmp folder. Any insight?

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    All sorts of things (say your editor) save all sorts of things (say a backup file) in /tmp

    Mostly, they get deleted when a program exits (though they might be left behind if the program crashes).
    Mostly, /tmp is cleared when you reboot.

    If you do
    ls -l /tmp
    and see things older than your last reboot, you might want to look into the second part.

    Or it's a sign that your disk itself is getting full, and you need to start cleaning up some junk.
    Code:
    $ df -BM
    Filesystem           1M-blocks      Used Available Use% Mounted on
    /dev/sdb5                5632M     4927M      419M  93% /
    Do you see a line just for /tmp?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    Salem, I guess because I wasn't using a cast it was crashing and slowly filling up my tmp dir. Maybe? I have compiled it before with no cast.
    There is def things older than my last reboot tho!

    This is the result for the ls -l /tmp:
    Code:
    ubuntu@ubuntu:~/Documents$ ls -l /tmp
    total 20
    srwxr-xr-x 1 ubuntu ubuntu     0 2011-06-23 03:10 gedit.ubuntu.898307530
    drwx------ 2 ubuntu ubuntu   100 2011-06-23 02:27 keyring-V2f3gh
    drwx------ 2 ubuntu ubuntu   680 2011-06-24 05:48 orbit-ubuntu
    drwx------ 2 ubuntu ubuntu    80 2011-06-23 00:31 pulse-HOZ09YZU5RId
    drwx------ 2 root   root      40 2011-06-23 02:28 pulse-PKdhtXMmr18n
    -rw-r--r-- 1 ubuntu ubuntu 16844 2011-06-23 02:28 s-c-screenshoth7DGCj
    drwx------ 2 ubuntu ubuntu    60 2011-06-23 02:27 ssh-xeFzaU4974
    drwx------ 2 ubuntu ubuntu    40 2011-06-23 02:27 virtual-ubuntu.AeQGWP
    ubuntu@ubuntu:~/Documents$
    Not sure as to what all this is, but hopefully you will!
    Btw, my HDD is trashed, so I run a live cd with no HD @ all.

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    > Btw, my HDD is trashed, so I run a live cd with no HD @ all.
    WHAT?!!

    So where do you save your work so it survives a reboot.
    Any writeable file system you have at this point is being faked by using RAM. So yeah, it's going to be in short supply.

    Or was this the "clue" in your original message?
    I have been coding a basic server twice a day for 2 weeks
    I thought this was practice, not necessity.

    If your machine will boot from USB, then a 2GB thumb drive will be a lot more useful to you than a CD. At least you'll get some persistent storage.

    This is one of those times where the "Remote Slap Protocol" would have come in handy!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  10. #10
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    Yeah, it has a few bad sectors. It won't let me install an OS. But Any work I do, I save in my documents and send a copy to my email. Because I have to reboot it often. It is practice tho. And I have an 8GB thumb drive...I guess I'll start using that now! And I dont know what a remote slap protocol is but I def deserve a slap lol

  11. #11
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    Quote Originally Posted by Salem View Post
    > Btw, my HDD is trashed, so I run a live cd with no HD @ all.
    WHAT?!!

    So where do you save your work so it survives a reboot.
    Any writeable file system you have at this point is being faked by using RAM. So yeah, it's going to be in short supply.

    Or was this the "clue" in your original message?

    I thought this was practice, not necessity.

    If your machine will boot from USB, then a 2GB thumb drive will be a lot more useful to you than a CD. At least you'll get some persistent storage.

    This is one of those times where the "Remote Slap Protocol" would have come in handy!
    Most live distros I've seen use a union mount to store persistent changes to the filesystem on for example an external USB drive. Maybe that is what the OP is using.

  12. #12
    Registered User
    Join Date
    May 2009
    Posts
    2,765
    Quote Originally Posted by Salem View Post
    This is one of those times where the "Remote Slap Protocol" would have come in handy!
    I could not find that protocol; is it your on joke protocol?

    April Fools' Day RFC - Wikipedia, the free encyclopedia

    But, I learned something new that they added QoS to IP over Avian Carriers protocol.
    It is so hard to keep up with the latest protocols

    Tim S.
    Salem likes this.

  13. #13
    Registered User
    Join Date
    Jun 2011
    Location
    Madeira Beach, Fl
    Posts
    1
    I give you guys much respect. I am still trying to figure this out.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error: was not declared in this scope compilation error
    By i_r_tomash in forum C Programming
    Replies: 2
    Last Post: 05-27-2010, 08:44 AM
  2. Compilation Error. Need help
    By CS_Student8337 in forum C Programming
    Replies: 4
    Last Post: 02-11-2009, 10:57 AM
  3. compilation error
    By blue_gene in forum C++ Programming
    Replies: 2
    Last Post: 04-13-2004, 08:26 AM
  4. compilation error
    By blue_gene in forum C++ Programming
    Replies: 1
    Last Post: 12-28-2003, 12:49 AM
  5. Error with compilation
    By mattbrrtt in forum C Programming
    Replies: 0
    Last Post: 01-08-2002, 04:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21