|
thank you Zac....i still get the same errors with or without the MFC socket extensions.
What are the header file for ifreq, sockaddr_ll structures??
thanks
|
|
|
|
|
They should be in the winsock2.h header (which is included from the afxsock.h file).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Those structures aren't include in winsock2.h
Another question, Is necessary put this lines before open a socket?
int wsaret=WSAStartup(0x101,&wsaData);
//WSAStartup returns zero on success.
//If it fails we exit.
if(wsaret!=0)
{
return 0;
}
|
|
|
|
|
afpr wrote: Another question, Is necessary put this lines before open a socket?
int wsaret=WSAStartup(0x101,&wsaData);
Only if you want it to work. Otherwise, you'll likely receive a WSANOTINITIALISED error.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You don't have to call that before you open each socket, but it does need to be called at some point in your application prior to opening a socket.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
To work with sendto() or recvfrom() functions, is it necessary to use WSAstartup function?
|
|
|
|
|
WSAStartup MUST be called once in your program before any socket operations can be performed. This is typically don't in the InitInstance method, but doesn't have to be.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
thanks Zac, but i have some errors, can you help me?
These are de errors:
1-
'DEVICE' : undeclared identifier
'ioctlsocket' : cannot convert parameter 3 from 'struct ifreq *' to 'unsigned long *'
in this lines:
strncpy(ifr.ifr_name, DEVICE, IFNAMSIZE);
if (ioctlsocket(s, SIOCGIFINDEX, &ifr) == -1) {
perror("SIOCGIFINDEX");
exit(1);
}
2-
'function-style cast' : illegal as right side of '.' operator
left of '.sa_data' must have class/struct/union type
in this line:
for (i = 0; i < 6; i++) {
src_mac[i] = ifr.sockaddrifr_hwaddr.sa_data[i]; src_mac is unsigned char src_mac[6]
}
3-
use of undefined type 'ethhdr'
see declaration of 'ethhdr'
left of '->h_proto' must point to class/struct/union
ETHER_TYPE_NULL' : undeclared identifier
in this line:
eh->h_proto = ETHER_TYPE_NULL;
4-
'gettimeofday' : undeclared identifier
in this line:
gettimeofday(&begin,NULL);
thanks
|
|
|
|
|
You need to include header file or files did you include files
|
|
|
|
|
i am using VC++6 with DOM creating and manuplating XML file.
i had created xml tags at run time and given default namespace , created some child nodes like this
<root xmlns="http://...">
<firstchild/>
<secondchild/>
</root>
,now i need to get the child from other part of the project so
I am using selectSingleNode() say like selectSingleNode("//root") but this is returning null so I used setProperty() to add a prefix to the namespace
and called the selectSingleNode("//pre:root") but still it is returning Null
y is it so
thanks in advance
|
|
|
|
|
I'm working with VC++6.0. I have a SDI application. I want to do unit test on some functions, but how do I run it?
Say I have a function
BOOL IsValid (MyType *p);
And the unit test I write for it is:
void TestIsValid()
When I run my application in Debug mode, how can I run "TestIsValid"?
Thank you very much for any help!
|
|
|
|
|
Use the #ifdef and #endif blocks:
BOOL IsValid (MyType *p) {
#ifdef _DEBUG
TestIsValid();
#endif
}
|
|
|
|
|
thank you, walder.
but in my "TestIsValid()", I will call "IsValid()", I'm afraid this will cause an infinite recurrent problem.
the other problem is, "IsValid( )" is called quite a few times in the application, I don't want to run the unit test code all the time.
Is there a way to get something like a shell window, and I just type in "TestIsValid" to get it run?
Thanks!
|
|
|
|
|
deport your unit tests into their own project into the solution, with a reference to the sources to be tested.
|
|
|
|
|
thank you, toxcct.
Can you elaborate on how to do that?
|
|
|
|
|
Sorry, I'm having a difficult time trying to understand what you are doing? It sounds like you have a function TestIsValid() which in turn calls IsValid() which in turn calls TestIsValid() , and so on... Perhaps you could show me some code.
You dont have to use the only the DEBUG definition, you can create your own
#ifdef DEBUG
#ifdef MYFUNC_1
#endif
#endif
|
|
|
|
|
do you know what unit tests are for ?
they are written to verify that management rules are correctly implemented. for this, unit tests can be ran, but they mustn't be included in the main project as their code is only for the development purpose...
|
|
|
|
|
toxcct wrote: for this, unit tests can be ran, but they mustn't be included in the main project as their code is only for the development purpose
That is, of course, unless you are following one of the Agile Design models. In almost all of those paradigms, the unit test cases should accompany the source code, but won't get linked into the final application (generally, you have a separate unit-test project file that has a main.cpp that simply calls all your unit tests and reports the results).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
To be honest I have never heard of them, but I guess they are something similar to the ASSERT() macro, only with more functionality.
|
|
|
|
|
waldermort wrote: To be honest I have never heard of them
You have never heard of unit tests?
waldermort wrote: similar to the ASSERT() macro, only with more functionality.
Not really. Unit tests isolate a module and do a thorough diagnostic on it. That is, a good unit test will test all the public methods of a module to make sure they give the desired results.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: You have never heard of unit tests?
That surprises you?
led mike
|
|
|
|
|
It does surprise me a bit. That is one of the topics that should be required for any computer science/computer engineering curiculum, but I guess some places don't think you need to test your work :-P
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: That is one of the topics that should be required
one of the "many" that aren't.
led mike
|
|
|
|
|
here's the sample code:
<br />
BOOL IsValid(MyType *p)<br />
{<br />
<br />
<br />
.....<br />
}<br />
<br />
void TestIsValid ()<br />
{<br />
MyType a;<br />
BOOL bRet;<br />
<br />
bRet = IsValid (&a);<br />
printf ("IsValid( ) returns %d.\n", bRet);<br />
}<br />
So I don't see I can use what you recommended first as:
<br />
BOOL IsValid (MyType *p)<br />
{<br />
...<br />
#ifdef _DEBUG<br />
TestIsValid();<br />
#endif<br />
}<br />
I hope I made myself clear this time.
|
|
|
|
|
So place it in the other function:
void TestIsValid()
{
MyType a;
BOOL bRet = false;
#ifdef _DEBUG
bRet = IsValid (&a);
printf ("IsValid( ) returns %d.\n", bRet);
#endif
}
|
|
|
|