Advertisement
Advertisement
| 05.07.2008 at 10:36AM PDT, ID: 23383614 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: |
printf("Connecting socket...");
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) == SOCKET_ERROR)
{
printf("ERROR: Cannot connect to server\n");
WSACleanup();
return(1);
}
printf("Connected\n");
|
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 05.07.2008 at 10:46AM PDT, ID: 21518695 |
| 05.07.2008 at 02:40PM PDT, ID: 21520570 |
| 05.07.2008 at 05:18PM PDT, ID: 21521421 |
| 05.07.2008 at 07:30PM PDT, ID: 21521918 |
| 05.07.2008 at 11:25PM PDT, ID: 21522670 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: |
/***********************************************/
/* SMTPTest.cpp */
/* A program to test SMTP mail communications */
/* */
/* Compile with: */
/* cl SPAMSend.c /link ws2_32.lib advapi32.lib */
/* */
/***********************************************/
#include <stdio.h>
#include <winsock.h>
/*****************/
/* MAIN FUNCTION */
/*****************/
void main(int nArgc, char *pArgv[] )
{
WSADATA wsaData;
SOCKET s; /* Socket identifier */
char buf[255]; /* Buffer for incoming */
int n; /* Bytes to read */
struct servent *ServEntry; /* Pointer to service info entry */
struct hostent *HostEntry;
struct sockaddr_in sin; /* Internet socket structure */
int type; /* socket type */
// Evaluate arguments
printf("SMTPTest v1.0\n\n");
if ( nArgc != 2 )
{
printf(" A program to test SMTP mail communications.\n");
printf("\nUsage:\t%s mailsystem\n\n", strupr(pArgv[0]));
printf("\tmailsystem = IP address or DNS name of mail forwarder\n");
return;
}
// Initialize WinSock
if (WSAStartup( MAKEWORD( 2, 0), &wsaData) != 0)
{
printf("ERROR: Error starting up WinSock\n");
return;
}
// Allocate a socket
s = socket(PF_INET, SOCK_STREAM, 0);
if ( s == INVALID_SOCKET )
{
printf("ERROR: Invalid socket\n");
WSACleanup();
return;
}
memset(&sin, 0, sizeof(sin)); // Clear out all variables in socket structure
sin.sin_family = AF_INET; // Set protocol to IP
// Set port to SMTP
if (ServEntry = getservbyname("smtp", "tcp"))
{
sin.sin_port = ServEntry->s_port;
}
else
{
printf("ERROR: Port discovery error\n");
WSACleanup();
return;
}
// Perform DNS resolution of IP address of mail server
if ( (sin.sin_addr.s_addr = inet_addr(pArgv[1])) == INADDR_NONE)
{
if ( HostEntry = gethostbyname(pArgv[1]) )
{
memcpy(&sin.sin_addr, HostEntry->h_addr, HostEntry->h_length);
}
else
{
printf("ERROR: Can't get \"%s\" host entry\n", pArgv[1]);
WSACleanup();
return;
}
}
printf("%s resolves to %s\n", pArgv[1], inet_ntoa(sin.sin_addr));
// Connect a TCP socket to the server
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) == SOCKET_ERROR)
{
printf("ERROR: Cannot connect to server\n");
WSACleanup();
return;
}
// Receive mail server header
buf[0] = '\0';
n = recv(s, buf, 255, 0);
if ( n == SOCKET_ERROR )
{
printf("ERROR: Cannot receive data\n");
goto Cleanup;
}
buf[n-1] = '\0';
printf("RECV> %s\n", buf);
// Send "helo" to the server
sprintf(buf, "helo company.com\r\n");
n = send(s, buf, strlen(buf), 0);
if ( n == SOCKET_ERROR )
{
printf("ERROR: Cannot send data\n");
goto Cleanup;
}
buf[strlen(buf)-1] = '\0';
printf("SEND> %s\n", buf);
// Receive "250 OK" response from server
buf[0] = '\0';
n = recv(s, buf, 255, 0);
if ( n == SOCKET_ERROR )
{
printf("ERROR: Cannot receive data\n");
goto Cleanup;
}
buf[n-1] = '\0';
printf("RECV> %s\n", buf);
// Send "Quit" to the server
sprintf(buf, "quit\r\n");
n = send(s, buf, strlen(buf), 0);
if ( n == SOCKET_ERROR )
{
printf("ERROR: Cannot send data\n");
goto Cleanup;
}
buf[strlen(buf)-1] = '\0';
printf("SEND> %s\n", buf);
// Receive "221 closing connection" from the server
n = recv(s, buf, 255, 0);
if ( n == SOCKET_ERROR )
{
printf("ERROR: Cannot receive data\n");
goto Cleanup;
}
buf[n-1] = '\0';
printf("RECV> %s\n", buf);
// Close TCP socket
Cleanup:
if (shutdown(s, 0) != 0)
{
printf("Error with shutdown\n");
WSACleanup();
return;
}
// Cleanup WinSock
if ( WSACleanup() != 0 )
{
printf("Error shutting down WinSock\n");
return;
}
return;
}
|
| 05.08.2008 at 01:52AM PDT, ID: 21523242 |
| 05.08.2008 at 02:02AM PDT, ID: 21523267 |
| 05.08.2008 at 08:29AM PDT, ID: 21525563 |
| 05.08.2008 at 09:27AM PDT, ID: 21526169 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: |
C:\Source\Work\SMTPTest>smtptest 192.168.1.104 SMTPTest v1.0 192.168.1.104 resolves to 192.168.1.104 Connected: 0 RECV> SEND> helo company.com RECV> SEND> quit ERROR: Cannot receive data C:\Source\Work\SMTPTest> |
| 05.08.2008 at 09:29AM PDT, ID: 21526185 |
1: |
printf("Connected: %u\n", WSAGetLastError());
|
| 05.08.2008 at 09:34AM PDT, ID: 21526235 |
| 05.08.2008 at 09:35AM PDT, ID: 21526264 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: |
C:\tmp\cc>smtptest srv2 SMTPTest v1.0 srv2 resolves to x.y.1.101 RECV> 220 srv2 Microsoft ESMTP MAIL Service, Version: 5.0.2195.6713 ready at Thu, 8 May 2008 ---------- SEND> helo company.com RECV> 250 srv2 Hello [x.y.1.20] SEND> quit RECV> 221 2.0.0 srv2 Service closing transmission channel C:\tmp\cc>smtptest mxp1 SMTPTest v1.0 xp1 resolves to x.y.1.20 ERROR: Cannot connect to server |
| 05.08.2008 at 10:43AM PDT, ID: 21526839 |
| 05.08.2008 at 04:32PM PDT, ID: 21529332 |