Bad File Number Error In C
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have
Bad File Descriptor Socket
Meta Discuss the workings and policies of this site About Us bad file descriptor linux Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with
Bad File Descriptor C
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just what is bad file descriptor like you, helping each other. Join them; it only takes a minute: Sign up why it can be “bad file number” when i write to socket up vote 0 down vote favorite I have a problem with sending message to server socket from client. write function returns error - bad file number. It means that I bad file descriptor error in c haven't permission to write to this socket. But from another client I can write to this socket, and do it successfully. Most interesting, that when another client connected to server my(problem) client can send message too. the code of my client: SOCKET OnceCommand; struct sockaddr_in SAddress4; struct autoC { char buf[4]; short fromx; short fromy; short tox; short toy; char step; char cycle; }; union autocomm{ char byte[14]; struct autoC command; } Command1, Command2; memset(&SAddress4,0,sizeof(SAddress4)); SAddress4.sin_family = AF_INET; SAddress4.sin_port = htons(444); SAddress4.sin_addr.s_addr = inet_addr(RobotsIP[Robot1]); memset(&(SAddress4.sin_zero),0,8); if((OnceCommand = socket(AF_INET,SOCK_STREAM,0))!=SOCKET_ERROR) { Err(OnceCommand); if(conn = connect(OnceCommand,(struct sockaddr *)&SAddress4,sizeof(struct sockaddr))!=SOCKET_ERROR) { rc = write(OnceCommand,(char*)Command1.byte,sizeof(Command1.byte)); if(rc < 0) { perror("Client-write() error"); rc = getsockopt(OnceCommand, SOL_SOCKET, SO_ERROR, &temp, &length); if(rc == 0) { Err(OnceCommand); perror("SO_ERROR was"); } closesocket(OnceCommand); } else { adv_printf("Client-write() is OK\n"); adv_printf("String successfully sent lol!\n"); } shutdown(OnceCommand,2); closesocket(OnceCommand); } } in SO_ERROR was "bad file number" I'm using sockets lib in ADAM-5510 microcontroller based with ROM-DOS. I tried to solve this problem by using NONBLOCKing sockets, but select ret
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with
What Does Bad File Descriptor Mean
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow bad file descriptor pipe Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Bad
Bad File Descriptor Vlc
file descriptor up vote 11 down vote favorite 1 I'm learning about file descriptors and I wrote this code: #include
Specific Boards Linux Programming Bad File number? Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems Thread: Bad File number? Thread http://cboard.cprogramming.com/linux-programming/18819-bad-file-number.html Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch http://computer-programming-forum.com/47-c-language/ae7477411b84b7fb.htm to Hybrid Mode Switch to Threaded Mode 05-30-2002 #1 Unregistered Guest Bad File number? Alright, as some of you know, I downloaded Cygwin to compile Unix code under windows. I have a MUD(Multi User Demension/Dungeon) that I am writing. I have a nice shell that allows player connection, and character creation. It compiled 100% fine under the Linux server I WAS using. Now bad file I downloaded Cygwin, and I have a slight problem. It compiles fine, with no errors. However, when I run the program it logs an error in the log files, and then shuts down. Heres the error I got: *Wed May 29 15:04:50 2002: mux select(): Bad file number* And Heres the Code that uses that: Code: ... int max_files; ... if ((max_files = getdtablesize()) == -1) { log_to_file(LOG_ERRNO, "getdtablesize()"); exit(EXIT_FAILURE); } is_running = TRUE; while (is_running) { FD_ZERO(&input_sfd); FD_ZERO(&output_sfd); bad file descriptor FD_ZERO(&exception_sfd); FD_SET(control, &input_sfd); for (con = first_con; con != NULL; con = con->next) { FD_SET(con->sd, &input_sfd); FD_SET(con->sd, &output_sfd); FD_SET(con->sd, &exception_sfd); } if (select(max_files, &input_sfd, &output_sfd, &exception_sfd, &tv_zero) == -1) { log_to_file(LOG_ERRNO, "mux select()"); exit(EXIT_FAILURE); } ... Some of that may be irrelevent... but you can see the 'mux select()' part. I figured bad file number means that it can't log the error number? I'm not sure. And I've no clue why it would be messing up. I'm not a genius at sockets, and I followed a unix tutorial and fumbled my way through creating the basic MUD engine, but it works fine. Well, it used to. Nothing has changed sense I compiled on the server. does anyone have a clue to why it is not working? Or point me in a general direction? Thanks! 05-30-2002 #2 Strut View Profile View Forum Posts Visit Homepage Registered User Join Date Sep 2001 Posts 44 Oops! Sorry! I enetered my password wrong on the above post. Just wanted you all to know who was posting. -g- [Strut] I lay on my bed watching the stars, and I thought to myself... Where the hell is my roof? 05-30-2002 #3 kwigibo View Profile View Forum Posts Registered User Join Date Sep 2001 Location Australia Posts 212 When using cygwin, there is a file in cywins' home directory something like "cygwing1.dll" or to that effect. this file has to be
: #define EBADF 9 /* Bad file number */ on a SGI Unix box. Thanx, Jim Amrhein Sat, 22 Apr 2000 03:00:00 GMT Lawrence Kir#2 / 3 Bad file number Quote:>Would anyone know what the error "Bad file number" means ? >I found the reference to it in Unix's errno.h file : >#define EBADF 9 /* Bad file number */ >on a SGI Unix box. It means the file descriptor you passed to a file handling function didn't refer to an open file. File handles are a Unix related issue so this is best discussed in comp.unix.programmer. -- ----------------------------------------- ----------------------------------------- Sat, 22 Apr 2000 03:00:00 GMT Ralph Silverm#3 / 3 Bad file number : Would anyone know what the error "Bad file number" means ? : I found the reference to it in Unix's errno.h file : : #define EBADF 9 /* Bad file number */ : on a SGI Unix box. : Thanx, : Jim Amrhein invalid file descriptor ... or file not open for purpose ... -- Ralph Silverman Tue, 25 Apr 2000 03:00:00 GMT Page 1 of 1 [ 3 post ] Relevant Pages 1. syslog() returns "bad file number" 2. BAD FILE NUMBER 3. bad file magic number? 4. Bad file magic number 5. GCC error: bad magic number 6. help: bad magic number 7. Help--bad article number error coming up 8. Finding the minimum number of a txt file of numbers using input redirection 9. Getting a file version number as a number 10. Bad Include (was bad library) 11. Bad Header File? 12. Bad Code From A Help File Powered by phpBB Forum Software