AtomicChip
Programmer
I'm creating a .dll for direct SMTP services just 'cuz I'm sick and tired of the silly little Outlook box popping up every time I want to send an e-mail. I'm running into difficulty in the connection part of the dll. The socket is initalized, created, and connection info for it is all set just fine, but for some reason whenever I try to connect, I keep getting the 10060 error (Timeout). Here is the code that I have come up with. Any help here would be greatly appreciated, and worth some big starts...
#include <windows.h>
#include <winsock.h>
#define PORTNUM 5000
#define NOMANGLE
int index = 0, iReturn;
char szClientA[100];
TCHAR szClientB[100];
TCHAR szError[100];
SOCKET ServerSock = INVALID_SOCKET;
SOCKADDR_IN destination_sin;
PHOSTENT phostent = NULL;
WSADATA WSAData;
NOMANGLE int _stdcall InitSock();
NOMANGLE int _stdcall CreateSock();
NOMANGLE int _stdcall SetConnectionInfo( LPCTSTR, unsigned int );
NOMANGLE int _stdcall ConnectToServer();
NOMANGLE int _stdcall InitSock()
{
if (WSAStartup (MAKEWORD(1,1), &WSAData) != 0)
{
return -1;
exit(0);
}
return 0;
}
NOMANGLE int _stdcall CreateSock()
{
if ((ServerSock = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
{
return -1;
exit(0);
}
return 0;
}
NOMANGLE int _stdcall SetConnectionInfo( LPCTSTR hostName, unsigned int port )
{
destination_sin.sin_family = AF_INET;
if ((phostent = gethostbyname (hostName)) == NULL)
{
closesocket (ServerSock);
return -1;
exit(0);
}
memcpy ((char FAR *)&(destination_sin.sin_addr), phostent->h_addr, phostent->h_length);
destination_sin.sin_port = htons (PORTNUM);
return 0;
}
NOMANGLE int _stdcall ConnectToServer()
{
if (connect (ServerSock, (PSOCKADDR) &destination_sin, sizeof (destination_sin)) == SOCKET_ERROR)
{
closesocket (ServerSock);
return -1;
exit(0);
}
return 0;
} -----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
#include <windows.h>
#include <winsock.h>
#define PORTNUM 5000
#define NOMANGLE
int index = 0, iReturn;
char szClientA[100];
TCHAR szClientB[100];
TCHAR szError[100];
SOCKET ServerSock = INVALID_SOCKET;
SOCKADDR_IN destination_sin;
PHOSTENT phostent = NULL;
WSADATA WSAData;
NOMANGLE int _stdcall InitSock();
NOMANGLE int _stdcall CreateSock();
NOMANGLE int _stdcall SetConnectionInfo( LPCTSTR, unsigned int );
NOMANGLE int _stdcall ConnectToServer();
NOMANGLE int _stdcall InitSock()
{
if (WSAStartup (MAKEWORD(1,1), &WSAData) != 0)
{
return -1;
exit(0);
}
return 0;
}
NOMANGLE int _stdcall CreateSock()
{
if ((ServerSock = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
{
return -1;
exit(0);
}
return 0;
}
NOMANGLE int _stdcall SetConnectionInfo( LPCTSTR hostName, unsigned int port )
{
destination_sin.sin_family = AF_INET;
if ((phostent = gethostbyname (hostName)) == NULL)
{
closesocket (ServerSock);
return -1;
exit(0);
}
memcpy ((char FAR *)&(destination_sin.sin_addr), phostent->h_addr, phostent->h_length);
destination_sin.sin_port = htons (PORTNUM);
return 0;
}
NOMANGLE int _stdcall ConnectToServer()
{
if (connect (ServerSock, (PSOCKADDR) &destination_sin, sizeof (destination_sin)) == SOCKET_ERROR)
{
closesocket (ServerSock);
return -1;
exit(0);
}
return 0;
} -----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy