Click to See Complete Forum and Search --> : Socket * member


kodeguruguy
April 21st, 2004, 12:26 PM
I'm trying to use a Socket type as one of my private members, but I keep on getting an error. Can anyone tell me how I can fix this. I'm new to .NET. Here's what's going on:

class Connection
{
private:
Socket * socket;
}

but when I do this, I get the following error:
error C3265: cannot declare a managed 'socket' in an unmanaged 'Connection'

What do I need to do to get rid of this error? Is this even possible, or am I not allowed to have a Socket * member?

Thanks.

BradenF
April 21st, 2004, 08:33 PM
Socket is a member of a managed type. Connection is not.

Try declaring the connection class like this.

__gc class Connection
{
private:
Socket * socket;
}

This makes the Connection class managed. Don't know if that will have other implications in your application, but that's the way to do it.