|
I am currently having a problem debugging with some legacy VS c++ code that uses a .Net 1.1 dll and reg free com.
The c++ code is able to run and make calls to the .net assembly with reg free com (side by side assemblies). The problem is debugging in VS 6. The debugger stops at the first call to the .net code. If I disable the manifests and regasm /codebase my dll I am able to debug with no problem. Has anyone had any experience with this before. We would like to keep using the manifests and side by side while debugging to avoid confusing the other developers.
|
|
|
|
|
Are you behind a firewall?
led mike
|
|
|
|
|
What does WSAaGetLastError report?
led mike
|
|
|
|
|
inet_addr() expects a dotted IP address. Is that what your getAddr() func returns?
If not, maybe you can use getaddrinfo() to resolve the name (google.com) to an address.
Mark
|
|
|
|
|
But what is the string value? An IP address "xxx.xxx.xxx.xxx" or a name "google.com"?
Mark
|
|
|
|
|
That won't work. You need to resolve google.com to an ip address (DNS works )
getaddrinfo() will use DNS if you have it configured (if you can post here I imagine you do)
Here's some sample code ripped right from MSDN...
char* ip = "google.com";
char* port = "80";
struct addrinfo aiHints;
struct addrinfo *aiList = NULL;
int retVal;
memset(&aiHints, 0, sizeof(aiHints));
aiHints.ai_family = AF_INET;
aiHints.ai_socktype = SOCK_STREAM;
aiHints.ai_protocol = IPPROTO_TCP;
if ((retVal = getaddrinfo(ip, port, &aiHints, &aiList)) != 0)
{
printf("getaddrinfo() failed.\n");
}
else
{
printf("getaddrinfo() succeeded.\n");
} On success, aiList will have all the info you need to make a connection.
Mark
|
|
|
|
|
Anywhere before you call connect(), in place of the code you posted that builds the address
(my_addr).
Where I used
char* ip = "google.com";
you can use your getAddr()
Where I used
char* port = "80";
you can either convert your returned getPort() to a string or use the service name instead
char* port = "http";
|
|
|
|
|
A deprecated solution...
sockaddr_in my_addr;
memset(&my_addr, 0, sizeof(sockaddr_in));
...
HOSTENT *pHostent = ::gethostbyname(getAddr( ));
if (pHostent && pHostent->h_addrtype == AF_INET)
{
my_addr.sin_family = AF_INET;
my_addr.sin_port = htons( getPort( ) );
my_addr.sin_addr = *(in_addr *)(pHostent->h_addr_list[0]);
if ( connect( hSocket, ( const struct sockaddr* ) &my_addr, sizeof( my_addr ) ) == SOCKET_ERROR )
{
return( false );
}
}
else
{
return( false );
}
|
|
|
|
|
if ( connect( hSocket, aiList[0].ai_addr, sizeof( aiList ) ) == -1 ) { return( false ); }
|
|
|
|
|
ack sorry
if ( connect( hSocket, aiList[0].ai_addr, sizeof( sockaddr ) ) == -1 ) { return( false ); }
If that doesn't work:
check aiList[0].ai_addr in debugger - is it valid address/port?
hSocket valid? Created as TCP socket?
WSAGetLastError() returns what after failed connect()?
|
|
|
|
|
10038
Socket operation on nonsocket.
An operation was attempted on something that is not a socket. Either the socket handle parameter
did not reference a valid socket, or for select, a member of an fd_set was not valid
|
|
|
|
|
Armond Sarkisian wrote: Can I zip up all four files and send it to you?
Before we do that, try this...I just connected to google.com - 3 different ip addresses returned
by DNS. step through this in the debugger. Notice I'm using ALL the info returned by getaddrinfo
to do the socket() and connect() calls. Does this all succeed for you?
char* ip = "google.com";
char* port = "80";
struct addrinfo aiHints;
struct addrinfo *aiList = NULL;
int retVal;
sockaddr addr;
memset(&aiHints, 0, sizeof(aiHints));
aiHints.ai_family = AF_INET;
aiHints.ai_socktype = SOCK_STREAM;
aiHints.ai_protocol = IPPROTO_TCP;
if ((retVal = getaddrinfo(ip, port, &aiHints, &aiList)) != 0)
{
printf("getaddrinfo() failed.\n");
}
else
{
int SockErr;
addrinfo *pAddrInfo = aiList;
while (pAddrInfo)
{
addr = *pAddrInfo->ai_addr;
SOCKET s = socket(pAddrInfo->ai_family, pAddrInfo->ai_socktype, pAddrInfo->ai_protocol);
if (s != INVALID_SOCKET)
{
if (SOCKET_ERROR == connect(s, &addr, sizeof(sockaddr)))
{
SockErr = WSAGetLastError();
}
closesocket(s);
}
else
{
SockErr = WSAGetLastError();
}
pAddrInfo = pAddrInfo->ai_next;
}
}
Same code without /pre tags...
char* ip = "google.com";
char* port = "80";
struct addrinfo aiHints;
struct addrinfo *aiList = NULL;
int retVal;
sockaddr addr;
memset(&aiHints, 0, sizeof(aiHints));
aiHints.ai_family = AF_INET;
aiHints.ai_socktype = SOCK_STREAM;
aiHints.ai_protocol = IPPROTO_TCP;
if ((retVal = getaddrinfo(ip, port, &aiHints, &aiList)) != 0)
{
printf("getaddrinfo() failed.\n");
}
else
{
int SockErr;
addrinfo *pAddrInfo = aiList;
while (pAddrInfo)
{
addr = *pAddrInfo->ai_addr;
SOCKET s = socket(pAddrInfo->ai_family, pAddrInfo->ai_socktype, pAddrInfo->ai_protocol);
if (s != INVALID_SOCKET)
{
if (SOCKET_ERROR == connect(s, &addr, sizeof(sockaddr)))
{
SockErr = WSAGetLastError();
}
closesocket(s);
}
else
{
SockErr = WSAGetLastError();
}
pAddrInfo = pAddrInfo->ai_next;
}
}
|
|
|
|
|
At the socket call I assume. WSAGetLastError() gives you what after that call?
|
|
|
|