Forum posts for snmp.exe

SNMP Extension Agent on Windows Server 2012 unable to connect to a port from which it needs …

New Update:
So on the Windows Server 2012, if I manually invoke snmp.exe from WindowsSystem32 to 'Run as Administrator', the problem goes away. I am not able to force the SNMP Service to start as Administrator on Windows Server 2012.

Here is my scenario:


Our SNMP Extension Agent creates a windows socket to connect with one of our
Agents on a specific port number to get some configuration
information which we propagate to the MIB Browser.
When we do a fresh install of our Application and then install
SNMP on Windows Server 2012, everything works very well.
After a reboot any SNMP request to our Extension Agent is timed out
by the MIB Broswer. I debugged from the Extension Agent and found
that some how on the connect() call we are getting a 'WSAEACCES
(10013) Permission denied error'. Look at the comment below in the code.
The same thing works well on a Windows Server 2008.


Below is the code snippet:

struct sockaddr_in dest;
int sockfd;
char buffer;
int bytes_read;
char portNumberStr[10];
int iResult;

struct addrinfo *result = NULL, *ptr = NULL, hints;

WORD wVersionRequested;
WSADATA wsaData;

wVersionRequested = MAKEWORD(2, 2);

iResult = WSAStartup(wVersionRequested, &wsaData);
if (iResult != 0)
{
int WSAError = WSAGetLastError();
return SOAP_NO_SOCKET_ERROR;
}

ZeroMemory( &hints, sizeof(hints) );
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
sprintf(portNumberStr, '%d', port_number);

iResult = getaddrinfo('127.0.0.1', portNumberStr, &hints, &result);
if (iResult != 0)
{
int WSAError = WSAGetLastError();
WSACleanup();
return SOAP_NO_SOCKET_ERROR;
}

// Loop through the results addrinfo structure
bool connectionSuccess = false;
for(ptr = result; ptr != NULL; ptr = result->ai_next)
{
// Create a socket
sockfd = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
if (INVALID_SOCKET == sockfd)
{
int WSAError = WSAGetLastError();
continue;
}

iResult = connect(sockfd, ptr->ai_addr, (int)ptr->ai_addrlen); // This is the call where I get a WSAEACCES (10013) error.

if (iResult == SOCKET_ERROR)
{
int WSAError = WSAGetLastError();
closesocket(sockfd);
continue;
}

connectionSuccess = true;
break;
}

// Clean up
freeaddrinfo(result);

if(false == connectionSuccess)
{
return SOAP_ERROR;
}

// Form the Request
*localRequest = 'Request goes in here'


// Send the message to the agent through a TCP socket.
send(sockfd,localRequest->c_str(),(int)localRequest->length(), 0);


// Clear out the request string so we can use it to hold a response.
*localRequest = '';

// Keep getting bytes from server until finished.
do
{
bytes_read = recv(sockfd, &buffer, sizeof(buffer), 0);
if ( bytes_read > 0 )
{
localRequest->append(1,buffer);
}
}
while ( bytes_read > 0 );

closesocket(sockfd);
WSACleanup();


The same code as a standalone application is able to communicate with our agent and get the desired data.

Kindly let me know what else I can try or if you need some more information.

Thanks and Regards
Aditya

View complete forum thread with replies

Other posts related to snmp.exe

See Related Forum Messages: Follow the Links Below to View Complete Thread

Info Agent's SNMP
Debugging my windows DLL that might be invoked from a Windows Service
SnmpExtensionTrap has a size limit?
SNMP traps not caught in Windows XP
SNMP Extension Agent on Windows Server 2012 unable to connect to a port from which it needs …

What is the carbon footprint of your coffee?

Is it low? Is it high? Can this things really kill the planet Earth? Maybe the answer will surprise you. Maybe not.