|
-
September 7th, 2009, 06:53 AM
#1
unable to create socket...
Well am trying to create a port scanner for which am trying to create a socket first and then trying to connect at that particular port but the problem is every time i try to create a socket it returns false.......please help as soon as possible......
Code:
BOOL CTrial1Dlg::test (CString IP,UINT nPort)
{
sock* pSocket;
pSocket = new sock;
ASSERT(pSocket);
if (!pSocket->Create())
{
delete pSocket;
pSocket = NULL;
MessageBox("hmmm");
return FALSE;
}
while (!pSocket->Connect(IP , nPort))
{
delete pSocket;
pSocket = NULL;
return FALSE;
}
pSocket->Close();
delete pSocket;
return TRUE;
}
above sock is a simple class derived from CSocket class.....
-
September 7th, 2009, 07:04 AM
#2
Re: unable to create socket...
1. Did you ever read the documentation about CSocket::Create in MSDN? 
CSocket::Create
BOOL Create( UINT nSocketPort = 0, int nSocketType = SOCK_STREAM, LPCTSTR lpszSocketAddress = NULL );
Return Value
Nonzero if the function is successful; otherwise 0, and a specific error code can be retrieved by calling GetLastError.
2. Is there any particular reason to use CSocket class (blocking sockets) rather than CAsyncSocket (non-blocking)?
Victor Nijegorodov
-
September 7th, 2009, 07:04 AM
#3
Re: unable to create socket...
Did you call AfxSocketInit during the startup of your program ?
-
September 7th, 2009, 07:09 AM
#4
Re: unable to create socket...
not explicilty......can i know how can i do this??
-
September 7th, 2009, 07:12 AM
#5
-
September 7th, 2009, 07:20 AM
#6
Re: unable to create socket...
thanks a lot it worked fine and sorry for not going through the link initially......
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|