Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSocket

Status
Not open for further replies.

makaveliuk

Programmer
Dec 1, 2003
46
0
0
GB
I am trying to do a simple data transfer with CSocket class, but I get a "Unhandled exception: Access denied" when I use the Create() method.

Any ideas why that should happen? Or another method?
 
Please post the code up to and including the Create call. My first hunch is that you are having a problem elsewhere.
 
The code is simple:

CSocket hSock;
hSock.Create();

I have reduced it that and it still crashes with the same exception, but if I replace Create() with Connect() it doesn't crash but obviously doesn't connect because the socket hasn't been created.
 
the problem is probably not related to CSocket. my bet is on either the setup of your Visual Studio, or your machine.

try rebooting, is the only advice i have :p
 
Why don't you use the debuger to look at the internals of the exeption class. If you can't get anything readable from that at least you know what kind of class is beeing thrown. You can 1:see if it has any member functions or variables that might help diagnose the problem and if so you can trap it and examine them. 2:You can do a search on that exeption and CSocket to see if it's a known problem

WR
 
Here is the output from the call stack:

CMapPtrToPtr::GetValueAt(void * 0x00000618) line 179 + 3 bytes
CAsyncSocket::LookupHandle(unsigned int 1560, int 0) line 385 + 15 bytes
CAsyncSocket::AttachHandle(unsigned int 1560, CAsyncSocket * 0x0012ee08 {CSocket}, int 0) line 407 + 13 bytes
CAsyncSocket::Socket(int 1, long 63, int 0, int 2) line 557
CAsyncSocket::Create(unsigned int 0, int 1, long 63, const char * 0x00000000) line 105 + 20 bytes

The error is happening at the point of calling GetValueAt() which is used in the Create() function.
 
1. Have initialized your application to work with Sockets? Eg:

Code:
BOOL CXyzApp::InitInstance()
{
	if (!AfxSocketInit())
	{
		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
		return FALSE;
	}
      ...
      ...
}

2. If you are using win 95/98 or suchlike, check if TCP/IP is properly installed on OS

/Srikanth

What happens if you’re scared half to death twice?
 
That was the problem! I did not know you had to do that!

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top