Click here to Skip to main content
16,006,493 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery3-Oct-07 12:59
Mark Salsbery3-Oct-07 12:59 
AnswerRe: Need a best possible alternative?? Pin
Nelek27-Sep-07 21:19
protectorNelek27-Sep-07 21:19 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish1-Oct-07 10:46
Kiran Satish1-Oct-07 10:46 
GeneralRe: Need a best possible alternative?? Pin
Nelek2-Oct-07 10:19
protectorNelek2-Oct-07 10:19 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery9-Oct-07 6:04
Mark Salsbery9-Oct-07 6:04 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish18-Jun-08 17:55
Kiran Satish18-Jun-08 17:55 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery19-Jun-08 6:40
Mark Salsbery19-Jun-08 6:40 
QuestionCString to char* leads to an exception Pin
Mike Borozdin27-Sep-07 6:41
Mike Borozdin27-Sep-07 6:41 
Hello,

I'm rewriting my console application in MFC. The applications is a port scanner and it works very fine in as a console application. However, when writing it in MFC I get an unhandled exception where it isn't supposed to be.

<br />
void CNetScanMfcDlg::OnBnClickedButton1()<br />
{<br />
	//...<br />
	LPTSTR host = m_host.GetBuffer(255); //m_host is a CString variable of the Edit control value<br />
	PortScanner portScanner((char*) host, m_startPort, m_endPort);<br />
	//...<br />
}<br />
PortScanner::PortScanner(char* sHost, int startPort, int endPort) {<br />
	address.sin_family = AF_INET;<br />
	hostent* host = gethostbyname(sHost);<br />
	address.sin_addr.s_addr = (unsigned long) atoi(host->h_addr_list[0]); //this leads to an exception<br />
	this->startPort = startPort;<br />
	this->endPort = endPort;<br />
}<br />


gethostbyname() appears to return NULL, but it's not a problem with the host itself if I put gethostbyname("localhost") it works fine. I believe the string conversion causes this problem.
QuestionRe: CString to char* leads to an exception Pin
David Crow27-Sep-07 7:20
David Crow27-Sep-07 7:20 
AnswerRe: CString to char* leads to an exception Pin
Mike Borozdin27-Sep-07 7:47
Mike Borozdin27-Sep-07 7:47 
QuestionRe: CString to char* leads to an exception Pin
David Crow27-Sep-07 7:51
David Crow27-Sep-07 7:51 
AnswerRe: CString to char* leads to an exception Pin
Mike Borozdin27-Sep-07 8:09
Mike Borozdin27-Sep-07 8:09 
QuestionRe: CString to char* leads to an exception Pin
David Crow27-Sep-07 8:14
David Crow27-Sep-07 8:14 
AnswerRe: CString to char* leads to an exception Pin
Mike Borozdin27-Sep-07 8:43
Mike Borozdin27-Sep-07 8:43 
QuestionRe: CString to char* leads to an exception Pin
David Crow27-Sep-07 8:46
David Crow27-Sep-07 8:46 
AnswerRe: CString to char* leads to an exception Pin
Mike Borozdin27-Sep-07 9:10
Mike Borozdin27-Sep-07 9:10 
GeneralRe: CString to char* leads to an exception Pin
David Crow27-Sep-07 9:16
David Crow27-Sep-07 9:16 
GeneralRe: CString to char* leads to an exception Pin
Mike Borozdin27-Sep-07 9:30
Mike Borozdin27-Sep-07 9:30 
GeneralRe: CString to char* leads to an exception Pin
David Crow27-Sep-07 9:34
David Crow27-Sep-07 9:34 
GeneralRe: CString to char* leads to an exception Pin
Mark Salsbery27-Sep-07 8:38
Mark Salsbery27-Sep-07 8:38 
GeneralRe: CString to char* leads to an exception Pin
Mike Borozdin27-Sep-07 8:44
Mike Borozdin27-Sep-07 8:44 
QuestionDDE Question Pin
__DanC__27-Sep-07 6:18
__DanC__27-Sep-07 6:18 
Questionextend the "Save As..." dialog Pin
carabutnicolae123427-Sep-07 5:39
carabutnicolae123427-Sep-07 5:39 
AnswerRe: extend the "Save As..." dialog Pin
Nelek28-Sep-07 0:37
protectorNelek28-Sep-07 0:37 
GeneralRe: extend the "Save As..." dialog Pin
carabutnicolae123428-Sep-07 3:52
carabutnicolae123428-Sep-07 3:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.