|
While it's not a solution to your question, I'd like to point something out.
Any network address that begins with 192.168 is an address in a private network. What this means is that, only computers in that network may access other devices within it.
As such, it's entirely safe for me to say that the IP of the machine I'm typing on right now is 192.168.43.156 , and that the address of my gateway (the 'side' of the router that my pc can see) is 192.168.43.1
If I browse to a 'WhatsMyIp' type of website, the address returned is the IP that the 'other side' of my router has - the address that CAN be seen from anyone connected to the web. This address is NOT safe to share publicly.
See here for more on private networks: http://en.wikipedia.org/wiki/Private_network[^]
|
|
|
|
|
Hi Guys,
Is there any way to validate a socket descriptor before doing any IO on it?
~ Vikram S
|
|
|
|
|
What do you mean by validate, against what criteria?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
For example I am holding an client socket connected with some server. The server goes down or network goes down. Before doing any action I want to know is the socket in good state.
|
|
|
|
|
Ah, the age old problem.
Look, when two asynchronous processes are communicating things can go wrong at any moment. Even if there was a great way for you to check to see if the socket is in a good state, 1/2 microsecond later it could go bad so you'd still have to handle the "bad state" case when you access the socket connection. Just because it was in a good state an instant ago doesn't mean it still is, that's the nature of asynchronous communications and networks.
The falicy is expecting orderly things to happen in a disorderly world. Better to concentrate your efforts in dealing with the "error conditions", trying to communicate with the socket and discovering it's in a "bad state" by handling the failure returns, timeouts, etc. Handle the "disorderly shutdown" cases and you'll discover that the "orderly shutdown" cases fall out nicely.
|
|
|
|
|
Besides the other reply note as well that there is no way to insure that a socket is working without sending something (reading will not work.)
|
|
|
|
|
I have 3 buttons on a dialod with tab stop property = false, sometimes if I click all buttons in random order a hover effect (round blue) comes around the 2 buttons simultaneouly. It don't disappear even after mouse is not on any button. I think It should not come. Can you please suggest any workaround?
|
|
|
|
|
Never seen or heard this behaviour described before. It does sound very strange. I just tried a win32 dialog-based project (compiled and run under win7 x64 home premium) yet was still unable to replicate this behaviour.
Can you show the DialogProc that you are using? Mine is below. (I have 5 buttons, only respond to the clicking of two of them)
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_BTN_QUIT:
EndDialog(hwndDlg, 0);
return TRUE;
case IDC_BTN_TEST:
MessageBox(hwndDlg, "You clicked \"Test\" button!", "Information", MB_ICONINFORMATION);
return TRUE;
}
}
return FALSE;
}
|
|
|
|
|
Using WinInet -
I tried to send some data to login a website.But its server need to check my cookie at the same time.If the cookie is not match,this login action will be faild.I called the CHttpFile::AddRequest to add my cookie into the http header,than called CHttpFile::SendRequest.But the server return an error message.I holded this msg to google.Someone said this meens to your cookie in error.An internet friend said can not add in cookie into header to send,but use the CInternetSession::SetCookie.
SetCookie?How to use it?Or in other way can help me?
PS:I am a Chinese.My English is not well.But I need your help.Thank!
MFC VC C++ WinInet
|
|
|
|
|
I can't figure out how to do template specialization. I have the following situation:
template <class T>
ContainerClass
{
T pop() { void push(T) {
T findNextItem(TypeEnum myType);
template <> MySpecificClass findNextItem<MyspecificClass>(TypeEnum myType);
};
Only the specific class (MySpecificClass) has the TypeEnum, so I want to write a function that's specific for that version of the class.
How do I do that? I get error messages along the lines of:
error: explicit specialization in non-namespace scope
error: expected ‘;’ at end of member declaration
error: declaration of
error: conflicts with previous declaration
modified 5-Mar-12 17:02pm.
|
|
|
|
|
The following is getting close - but I get an error complaining of multiple definitions, both pointing to the implementation of the function??
Note: By the way I'm using gcc on Ubuntu.
template <class T>
ContainerClass
{
T pop() { void push(T) {
T findNextItem(TypeEnum myType);
};
template <>
MySpecificClass ContainerClass<MySpecificClass >::findNextItem(TypeEnum myType)
{
}
modified 5-Mar-12 18:26pm.
|
|
|
|
|
The following compiles for me.
I'm using VC 2010.
enum TypeEnum {};
class MySpecificClass {};
template <class T>
class ContainerClass
{
T pop() {}
void push(T) {}
T findNextItem(TypeEnum myType);
};
template <>
MySpecificClass ContainerClass<MySpecificClass>::findNextItem(TypeEnum myType)
{
return MySpecificClass();
}
int _tmain(int argc, _TCHAR* argv[])
{
ContainerClass<int> a;
ContainerClass<MySpecificClass> b;
return 0;
}
|
|
|
|
|
I need to add a software update check to my program. I started by writing a winsock function and making a call to my web site to get a document using
trncpy_s( sendbuf, 1024, "GET /updates/siteAdministrator.exe.txt HTTP/1.0\r\n", strlen( "GET /updates/siteAdministrator.exe.txt HTTP/1.0\r\n") );
strncat_s( sendbuf, 1024, "Host: www.website.com\r\n", strlen( "Host: www.website.com\r\n" ) );
strncat_s( sendbuf, 1024, "\r\n", strlen( "\r\n" ) );
My Question 1 is:
Without downloading other pre-fabricated programs that does this, or trying to reverse engineer other programs,
What would you recommend that I connect to just to get going at a beginners level. Perhaps a web service that returns the current version, or just a text file that contains the current version, and what information should I return?
If it's a text file, what recommended format would you suggest?
Question 2:
I'm looking for a way to resolve a URL to an IP Address, for this part of my winsock. I don't want to hard code it, because inside my LAN, I use private numbers, and outside my LAN is public numbers.
sTargetDevice.sin_family = PF_INET;
sTargetDevice.sin_addr.s_addr = inet_addr( ipAddress );
sTargetDevice.sin_port = htons((unsigned short) ipPort);
|
|
|
|
|
jkirkerx wrote: I'm looking for a way to resolve a URL to an IP Address...
Are you referring to gethostbyname() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Jeopardy Answer, I will give that a try.
Thanks Dave,
Will let you know how it works out.
|
|
|
|
|
I would use a text file with a specific format (eg XML). The content depends on your requirements. Useful information are version, date, and URL of the update archive/executable file (so it can be stored on another host).
To resolve a host name to an IP address, use the Winsock function getaddrinfo [^].
|
|
|
|
|
I thought about xml, but I need to learn how to read XML in c++ win32.
Those are good ideas, I'm going to finish my splash dialog and wait for some more ideas today.
|
|
|
|
|
It would be well worth your time to learn to create and process XML in both C++ and C#. XML comes in real handy these days. Hardly anybody but us dinosaurs read flat text files anymore.
|
|
|
|
|
In vb, I use XMLTextWriter and XMLTextReader while creating a class of an XSD model file. I'm really good at it.
Just thought doing it in c++ would be a very long journey, but overall, I need to write a ton of XML configuration files for my program anyways, so the journey begins tomorrow.
Thanks Chuck.
|
|
|
|
|
Windows? !Windows? - I know, "winsock" might be a clue
If you are using Windows, why bother playing using sockets and use WinINet, it will do all the address translations, proxy-crap, etc for you.
The sequence there would be
InternetOpen()
InternetOpenURL()
HttpQueryInfo()
InternetReadFile()
for the URL, you'd just pass "http://www.website.com/updates/siteAdministrator.exe.txt". Use HttpQueryInfo() to find out how much output is coming back and InternetReadFile() to fetch it all.
|
|
|
|
|
I didn't know about it!
Does sound easier. That's why I was looking for ideas.
I'll check it out.
FYI:
It's hard to find solutions when you don't even know what to call them, let alone know that they exist.
Thanks Chuck.
|
|
|
|
|
Hello,
I was wondering if any of you'll know any native compilers or compilers the use the very, very first form/version of C++ (like it came from Bjarne Stroustrip) and also some C compilers, try to suggest free ones.
Regards,
Brandon T. H.
|
|
|
|
|
I'm not certain I understand what you want.
You want the first "C++" compiler (or probably at that time C compiler that support the C++ extensions) ?
For free C/C++ compilers, have a look at GCC and G++.
Watched code never compiles.
|
|
|
|
|
Maximilien wrote: I'm not certain I understand what you want.
Maximilien wrote: You want the first "C++" compiler
Yes, the very first form of C++, or some un-managed C++ compilers.
|
|
|
|
|
Brandon T. H. wrote: Yes, the very first form of C++, or some un-managed C++ compilers.
There's a big difference. Most free C++ ones only compile 'unmanaged' (that is native) C++ (even the Microsoft C++ one compiles the native C++ , it is NOT 'only for managed C++ '). On the other hand, C++ has evolved (improved) and you'll probably find that an updated compiler is way better than an old one.
Veni, vidi, vici.
|
|
|
|