-
Assertion Failure
Hey, im working on this code, and I keep getting an assertion failure.
ws_fdr= fdopen(ws_sockfd,"r");
ws_fdw= fdopen(ws_sockfd,"w");
if you are wondering, ws_sockfd is an integer and equale to 1896 after going through this if statement:
if ( (ws_sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
err(WARN,"Wave_Server: socket connect error\n");
please help.
-
What's the assertion you're getting, and what line is it in?
Quzah.
-
I Get a debug assertion failure when the program is trying to execute either of the following statements:
ws_fdr= fdopen(ws_sockfd,"r");
ws_fdw= fdopen(ws_sockfd,"w");
I have posted the code to the FUNCTION on this website, so I'll send you the link. The error occurs in between the lines of 90 and 100. You'll see it because its numbered in the side, so you'll know what line you are on. It's the same code. Anyways, heres the site, I hope someone can help me.
http://sourcepost.sytes.net/sourcevi...ource_id=14603
-
What OS/compiler are you using?
-
Serves you right for using global variables. ;) Seriously though, when hunting down pain in the ass problems, it actually helps if you provide all variable declarations, especially since they're being used in the lines in question.
Quzah.
-
I'm using MS Visual C++ 6.0. This code actually works on UNIX, and I am attempting to change this into a Windows program. I'm coding it in C. I have now posted the entire code on this website, and the errors are now between 00630 and 00640.
Heres the site to see my code:
http://sourcepost.sytes.net/sourcevi...ource_id=14614
Please help.
Thanks :-)
-
In Windows, a socket is not a file descriptor. To get a file descriptor from a socket you can use _open_osfhandle(). You must call _close() on the resulting file descriptor and closesocket() on the original socket when you are done.
-
Can you give me an example with the code I have, because I'm kind of puzzled on how to do that.
Thanks
-
Code:
/* Get a file descriptor for the socket. */
int fd_rd = _open_osfhandle(ws_sockfd, _O_RDONLY);
/* Error handling */
if (fd_rd == -1) exit(-1);
/* Get a stream for the file descriptor. */
ws_fdr = fdopen(fd_rd,"r");
and cleanup:
Code:
/* Close stream */
fclose(ws_fdr);
/* Close file descriptor */
_close(fd_rd);
/* Close socket */
closesocket(ws_sockfd);
-
I received this error when trying to use that code:
D:\Documents and Settings\Omar\Desktop\lqshow\MSVC_STP\Stp_Demo.c(6 46) : error C2065: '_O_RDONLY' : undeclared identifier
What is _O_RDONLY, or what header files should I include to get that.
-
For future reference:
- Open your favourite search engine.
- Type the function name in.
- Click on the documentation page(usually the first result).
- Look at which header file is required.
In this case you need <io.h>
-
I included io.h, but it still didnt work, however, i went to a website and it had 0 in for that, so i substituted it in, and it worked. Thanks a bunch man, I owe you. :-)
Thanks