|
CresShadow wrote: it is to check that computer is on the network.
Pinging a computer is not a reliable way of determining if it is available/online.
CresShadow wrote: now it is single processing. so i think it implement multithread...
Think again. Adding additional threads to an application may improve its design but it will surely slow it down. Too much context switching.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
CresShadow wrote: now it is single processing. so i think it implement multithread and
broadcasting method. but i have no idea receiving all broadcast respond
What? Are you suggesting you can use broadcasting to implement port scanning of remote machines if only you knew how to receive responses? You better do some more studying on Sockets because you are totally lost. Since the most frequent use of Port Scanning is for malicious purposes, why do you need to do this? We don't support hackers here at Code Project.
led mike
|
|
|
|
|
led mike wrote: We don't support hackers here at Code Project.
Thx sir, may I know, then, where do you support them (plz plz)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I wanna know that computers on the network are online or offline.
I do not have any malicious purpose. ^^;
|
|
|
|
|
CresShadow wrote: I wanna know that computers on the network are online or offline.
Define online
Define offline
led mike
|
|
|
|
|
Hi Guys,
I'm not much of a programmer, so bear with me please.
I'm trying to program a standard Ant Algorithm/Ant Colony Optimization in C++, to search through a basic maze of open and closed (1 for open, 0 for closed) nodes to simulate a basic network.
Now I have the program functioning correctly for one ant, just runs through it once until its had its maximum number of moves or it finds the destination node.
I am trying to convert this into a class, so I can have multiple instances of the class (multiple ants) going through the network at once. My question is; how do I accomplish something like this? Currently, for my Ant Class I have :
class ant {
coordStruct route[300];
pheremoneStruct location[1];
public:
void set_route (int,int);
void set_location (int,int);
void set_coordPheremone (int,int,int);
} ant;
Will this work? If I perform all of the calculations and such outside of the class via get/set functions? or should I move the actual methods themselves into the class like below?
class ant {
coordStruct route[300];
pheremoneStruct location[1];
public:
void set_route (int,int);
void set_location (int,int);
void set_coordPheremone (int,int,int);
} ant;
I hope I've explained this clearly... But any help is appreciated, or any links to the code of something similar to give me an idea of what to do would also be helpful!
Thanks a lot.
Roppa
|
|
|
|
|
Put the method in the class.
This is after all, what encapsulation is all about - encapsulating the data and functions used to operate on it all into one neat packaged unit.
If it were me, I'd make it a virtual function, so that if, for whatever reason, you then need to simulate a different species of ant that makes decisions on its path differently, just inherit from this class and re-write the nextMove method.
|
|
|
|
|
Ah alright, any chance you could give me a little example of encapsulation?
Doesnt have to be anything fancy, just like an if/for loop or something so I can get an idea of how they work.
Many thanks for your help.
Roppa
|
|
|
|
|
Encapsulation, you know - wrapping together.
Here's a dog-n-bird example (ruff,ruff - cheep,cheep)
Notice the way that all the functions & required to turn an input string into a serial number are wrapped up inside the class. I don't have to know anything about the internal particulars in order to use the class. I just give an input string and recieve from it an output string. This is what I mean with your code. To make the ant truly autonomous, wrap all of the required functions and data up into a single class.
#include <iostream>
using namespace std;
class myExample
{
public:
myExample(char *inputString = "default")
{
m_Str = new char[strlen(inputString)+1];
strcpy(m_Str, inputString);
m_SecretResult = NULL;
superSecretNumberGenerator();
}
~myExample()
{
delete m_SecretResult;
delete m_Str;
}
char *getResult()
{
return m_SecretResult;
}
void setString(char *inputString)
{
delete m_SecretResult;
delete m_Str;
m_Str = new char[strlen(inputString)+1];
strcpy(m_Str, inputString);
m_SecretResult = NULL;
superSecretNumberGenerator();
}
private:
char *m_Str;
char *m_SecretResult;
virtual void superSecretNumberGenerator()
{
int i;
int sLen;
int tmpNum;
char tmp1[100];
char tmp2[100];
char tmp3[100];
sLen = strlen(m_Str);
if (sLen > 50)
sLen = 50;
if (m_SecretResult)
free (m_SecretResult);
for (i=0; i<sLen; i++)
tmp1[i] = m_Str[i]+3;
sprintf(tmp2, "%d", 1234567890*sLen);
sprintf(tmp3, "%s-%s-Enzflep", tmp1, tmp2);
m_SecretResult = new char[strlen(tmp3)+1];
strcpy(m_SecretResult, tmp3);
}
};
int main()
{
myExample *test = new myExample;
cout << "Result is: " << test->getResult() << endl;
test->setString("enhzflep");
cout << "Result is: " << test->getResult() << endl;
delete test;
system("Pause");
return 0;
}
|
|
|
|
|
Ah, fantastic reply.
I get it now. Many thanks my friend!
|
|
|
|
|
We want to buy a RFID reader now.
If you are using RFID readers, please let me know which product and company developed it are better.
Basically, I hope the reader can read/write Tag ID and all user data properly.
We have bought 2 readers, but they can not do the basic requirements properly.
A RFID reader is around $2,000 normally, we can not buy more again before we know which product is better.
I think the best info is from C++ programmers, so I post here for getting your help.
Thanks.
|
|
|
|
|
check out this site, this might be very useful, my old company use hardware from this company! :-
http://www.esslindia.com/[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
For some reasons, I need to create C++ collection classes myself.
The array and list are easy to be understood and created.
Now I want to create a map or bag class.
First thing I think I need to do is to know how to create HashTable for the map class.
But I don't know detail concept of HashTable structure in C++.
For example, a list collection has a set of objects which contain pointer to next object - this is basic concept of a list collection.
I need similar concept for HashTable or Map collection, which is enough to complete them in C++.
Any samples, comments and links are highly approciated.
Thanks
|
|
|
|
|
MFC has a CMap class and its source is available....
Judy
|
|
|
|
|
|
includeh10 wrote: First thing I think I need to do is to know how to create HashTable for the map class.
Read up on the subject here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: Read up on the subject here.
I'm not used to asking questions in CodeProject forums but I'll give it a try.
Which is more difficult?
1) Understanding instructional material on writing C++ code for a Hashtable
OR
2) Figuring out how to use Google to search for instructional material on writing C++ code for a Hashtable
led mike
|
|
|
|
|
i like the second one!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
led mike wrote: 2) Figuring out how to use Google to search for...
See if this helps.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all,
I'm running VC6 on 64-bit Vista, not an ideal situation I know but most things seem to be working for my app. However, I'm having one problem I can't seem to figure out.
I have two GUI programs in my app. When the first program is running I sometimes want to open the second program as a local server using Automation (e.g. both programs are .exe files). However, as outlined in the subject line, OleRun in COleDispatchDriver::CreateDispatch returns REGDB_E_CLASSNOTREG even after CoCreateInstance in the same function returns with no problem. I believe my registry settings are ok since I can pass data to the second program if it is already running. However, I just can't get it to start running if it is not already running.
I'm logged in with an administrator account and the problem happens whether or not User Account Control is enabled. I've moved all my registry keys to HKEY_CURRENT_USER but this doesn't seem to help either. I'm not all that familiar with COM/Automation so maybe the problem is related to that.
Any help for this out there?
Thanks,
Kevin
|
|
|
|
|
Kevin 1233412 wrote: but most things seem to be working for my app.
and they might work again[^]
I have no idea what might be the problem so this is just a WAG, are you building your projects using the Platform SDK for Vista and you have set WINVER appropriately?
led mike
|
|
|
|
|
Hi,
I'm having some trouble using classes defined in one project (compiled as exe) in another project (also to be compiled as exe, to run in a separate process, but part of the same solution). Is it possible at all? Or do I have to import all the .cpp files into the other project and compile them there?
I've set up a project dependency, but that doesn't work. I get unresolved externals during compilation.
Note, I've also set up project references.
modified on Thursday, July 17, 2008 12:45 PM
|
|
|
|
|
All the code an individual project needs to build must be
part of the project, or available to the project through a
library.
How you manage the physical files is up to you.
I personally use a "common" folder in the solution's folder to
keep my common/shared cpp/.h files in one location - only one codebase
to update. All projects can reference files there using relative paths,
something like "..\common\somecommoncode.h".
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
When I create the dialog box (second dialog) in the first dialog box it stays always above the first one. I can push to a button in the first dialog box while the second one stays above it.But when I create them at the begining of the program in the main dialog box (main dialog box is different than the first dialog box) then if I touch to the first dialog box the second one goes below the first one.How can I fix the second dialog box above the first dialog box when I create them at the beginning of the program?
Thanks
ibrahim
|
|
|
|
|