|
Have you set your router up to port forward requests from the outside world to your machine? Have you open up that port on your firewall? You need to bind to your local IP address (192.168....) and have the router forward those external requests to your machine.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
Thank you so much, it worked.
Now I want to develop the program and write a program such as NETCAT. I want the victim stays at listening state after running the program.
The question is how the victim get its public IP to stays at listening state with that IP?
|
|
|
|
|
Not sure what you mean by victim, nor am I familiar with netcat. Try clarifying your question and perhaps create a new thread on this forum.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
ok. Here is about NETCAT (http://en.wikipedia.org/wiki/Netcat)
I have written a program in two client and server versions. The server program must be run on the victim computer. I’m controlling the whole of the victim computer by client program. I’ve written this program for LAN. Now I want this program works on the internet while controlling that victim computer with the server program on. The victim computer is connected to the internet by and ADSL broadband. My problem is when the server program is being run on the victim computer, how it can get the Public IP and then stays at listening state on that IP address?
|
|
|
|
|
Sounds difficult, as the ADSL router probably doesn't have a static IP address, but if it did, the server software would listen to the local machines' (private) IP address (this probably isn't static either), and the ADSL router would need to have port forwarding setup to send your server machine incoming packets. Lots of this (I'm guessing) is not done programatically. here[^] is an example of the type of setup needed.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
Dear friend, It’s not important if that public IP (ADSL IP) be static or dynamic. The code below gets public IP of that computer and it must be able bind that IP to the created socket and then stays at the listening state:
...
HINTERNET hI, hF;
DWORD piSize;
char public_ip[15];
hI= InternetOpen(NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
hF = InternetOpenUrlA(hI, "http://myip.dnsomatic.com", NULL, 0, INTERNET_FLAG_RELOAD, 0);
InternetReadFile(hF, &public_ip, sizeof(public_ip), &piSize);
public_ip[piSize] = '\0';
InternetCloseHandle(hF);
InternetCloseHandle(hI);
cout << public_ip;
...
The main problem is that my server program can’t bind to received public IP.
|
|
|
|
|
You want to bind to an IP address associated with a NIC on a seperate device (ADSL router)? If so, I don't think you can, and you don't need to (think port forwarding). If not, I'm still not sure what your question is.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
It's confusing!
Let’s imagine my public IP address is 86.57.91.237.
Now I want to use that IP in the code below:
...
WSAData ws;
struct sockaddr_in sock;
int resSock, bnd;
WSAStartup(MAKEWORD(2, 2), &ws);
resSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (resSock != INVALID_SOCKET){
sock.sin_family = AF_INET;
sock.sin_port = htons(3377);
sock.sin_addr.S_un.S_addr = inet_addr("86.57.91.237");
}
bnd=bind(resSock, (struct sockaddr *)&sock, sizeof(sock));
if (bnd != SOCKET_ERROR)
cout << "Bind Successful" << endl;
else
cout << GetLastError() << endl;
...
why does this program show error code 10049? Error code 10049 means:
“The requested address is not valid in its context. This normally results from an attempt to bind to an address that is not valid for the local computer”.
I want to see “Bind Successful” message.
|
|
|
|
|
Run "ipconfig /all" at the command prompt. Look at the results, there should be data given about each NIC card on YOUR machine. Look at the line that says "IP Address.......xxx.xxx.xxx.xxx" (there may be several). Make a list of these IP addresses. If "86.57.91.237" is not in that list, then you can not bind to it. Meaning it is not an IP address associated with a NIC on your computer.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
Here is my Program
In the line int GCD(num1,num2) I get the warning
" warning: parameter names (without types) in function declaration [enabled by default]| "
But if I use int GCD(int a,int b) the warning is not there.
NOTE - In both cases the program runs perfectly.
I am a newbie, so I would appreciate if someone helps me regarding this....
/* I am using mingw with code blocks */
#include<math.h>
#include<stdio.h>
#include<conio.h>
int GCD(num1,num2);
main()
{
int num1,num2;
printf("\n\tEnter the two numbers whose GCD is to be found : ");
scanf("%d %d",&num1,&num2);
printf("\n\tGCD of %d & %d is %d",num1,num2,GCD(num1,num2));
getch();
}
int GCD(int a ,int b)
{
if (b>a)
return GCD(b,a);
if(b==0)
return a;
else
return GCD(b,a%b);
}
#include<math.h>
#include<stdio.h>
#include<conio.h>
int GCD(num1,num2);
main()
{
int num1,num2;
printf("\n\tEnter the two numbers whose GCD is to be found : ");
scanf("%d %d",&num1,&num2);
printf("\n\tGCD of %d & %d is %d",num1,num2,GCD(num1,num2));
getch();
}
int GCD(int a ,int b)
{
if (b>a)
return GCD(b,a);
if(b==0)
return a;
else
return GCD(b,a%b);
}
#include<math.h>
#include<stdio.h>
#include<conio.h>
int GCD(num1,num2);
main()
{
int num1,num2;
printf("\n\tEnter the two numbers whose GCD is to be found : ");
scanf("%d %d",&num1,&num2);
printf("\n\tGCD of %d & %d is %d",num1,num2,GCD(num1,num2));
getch();
}
int GCD(int a ,int b)
{
if (b>a)
return GCD(b,a);
if(b==0)
return a;
else
return GCD(b,a%b);
}
|
|
|
|
|
You should always declare the parameter types to avoid confusion.
|
|
|
|
|
So i need to specify that they are integers, right ? 
|
|
|
|
|
|
Driganka Mandal wrote: int GCD(num1,num2);
int is the default type... but that function declaration isn't exactly kosher (think it would be invalid for any C compiler, C++ compilers tend to be more forgiving but that doesn't mean it's part of the standard).
|
|
|
|
|
Quote: Is it possible of getting same answer for inverse of matrix 100*100 dimension using gsl lib and matlab
|
|
|
|
|
Of course you must get the same answer (within rounding effects), otherwise one (or both) libraries would have been broken.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Hi
I have old dictionary software (English-arabic) and i want to ask if there is a way to extract the dictionary data to text or excel ? just tell me how
the software coded in visual C++ 
|
|
|
|
|
It depends what you mean by 'extract'. You would need to know the structure of the data on the disk, and design a structure for the system you want to store it on. The issue is a matter of design rather than programming.
|
|
|
|
|
Could you please tell me how to get Google's PageRank for a desired web page using C++ language? Thank you!
|
|
|
|
|
You might start here.
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi,
I have a dialog form inside a pane that has a popup menu which messages are handled in the CMainFrame. I am doing this because the same menu exists also in another pane.
In this case, the acceleratos of the Dialog's popupmenu are hidden since the MFC framework does not "see" any message handlers inside the dialog. The messages as I said before, are handled in the CMainFrame. The accelerators itself works just fine, the only problem is that does not show up in the screen to inform the user.
So, how to force MFC framework to show the dialog's accelerator keys ? I tried to add message handlers in the dialog class but it didn't worked.
sdancer75
|
|
|
|
|
Going on a screen-shot in this article: An examination of menus from a beginner's point of view[^]
Particularly, this image: http://www.codeproject.com/KB/menus/MenusForBeginners/MenuItemEdit.jpg[^]
You can see that adding a tab character and then the text to indicate the accelerator is the way it's done.
So, to make a menu item that says "Bold" and indicates the functionality can be achieved by hitting Ctrl-B, I'd use the text "Bold\tCtrl-B". Unlike the use of the & character to underline the following letter _and_ make the folowing letter actually work, with accelerators, you have to add the text and the accelerator yourself in 2 steps. One as I mentioned, by adding a tab separator between the main text and the accelerator text and the other, by adding an accelerator table,as you've already done.
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
Hi,
You may did not understand the problem. The menus are created dynamically and they have their accelerators shortcut keys as declared below.
VERIFY(popmenu.CreatePopupMenu());
popmenu.AppendMenu(MF_STRING, ID_MENU_STRETCH_NORMAL, _T("&Option 1\tAlt+1"));
popmenu.AppendMenu(MF_STRING, ID_MENU_STRETCH_MAX, _T("&Option 2\tAlt+2"));
The problem is that when the popup is showning up to the screen, the acceleratos keys are hidden for the reason I explained in my first post.
Regards,
sdancer75
|
|
|
|
|
sdancer75 wrote: Hi,
You may did not understand the problem.
Hi,
Yes, I think that is true.
If I understand correctly, the accelerator 'hints' on the popup menu are fine. However, when the popup is displayed, the accelerator hints of the dialog are hidden.
If so, I'm still not sure I understand what the issue is - i.e, a popup menu has the keyboard and mouse focus until it dissapears. It is the WindowProc of the popup that receives all input, so in that case it seems to me, that displaying the accelerators of the dialog would not be useful.
However, you've already mentioned that the accelerators are working correctly. This, combined with the thread title and your last post leaves me confused as to what your intentions and problem are.
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
enhzflep wrote: If I understand correctly, the accelerator 'hints' on the popup menu are fine. However, when the popup is displayed, the accelerator hints of the dialog are hidden.
That's correct.
By default if you start a new MFC app and you create a menu that have some acceleration keys, if you are not handling in some way their messages ie loading the accel table, then it automatically disables them.
The problem is that I handle the accel keys not in the dialog but in the MainFrame where the same menu also exists !!!
Regards,
sdancer75
|
|
|
|
|