Click here to Skip to main content
16,016,184 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralBitmap Masking.. Pin
Neha28-Nov-01 0:36
Neha28-Nov-01 0:36 
GeneralRe: Bitmap Masking.. Pin
Christian Graus28-Nov-01 1:50
protectorChristian Graus28-Nov-01 1:50 
GeneralRe: Bitmap Masking.. Pin
Neha28-Nov-01 16:59
Neha28-Nov-01 16:59 
GeneralRe: Bitmap Masking.. Pin
Christian Graus28-Nov-01 17:14
protectorChristian Graus28-Nov-01 17:14 
General::listen() function gotcha ?!?!?! Pin
Davide Calabro27-Nov-01 23:34
Davide Calabro27-Nov-01 23:34 
GeneralRe: ::listen() function gotcha ?!?!?! Pin
Nish Nishant27-Nov-01 23:39
sitebuilderNish Nishant27-Nov-01 23:39 
GeneralRe: ::listen() function gotcha ?!?!?! Pin
Davide Calabro28-Nov-01 1:54
Davide Calabro28-Nov-01 1:54 
GeneralSocket connect function fails and WSAGetLastError returns WSAECONNREFUSED in a WIN32 service Pin
27-Nov-01 23:13
suss27-Nov-01 23:13 
Hi I am using the following function to send a mail.
In a normal exe if I use it it works properly.But I have converted my application into a service.
Then in the following function connect function fails and WSAGetLastError returns error WSAECONNREFUSED.

int CSMTP::SMTPSendMail(char *lpszMail)
{

char szHostName[100];
SOCKET sSock;
bool bData = FALSE;
int iErr;
char szSendBuf[1000];
char szRecvBuf[2000];
int iSend = 0;
int iCount = 0;
int PORT=25;
DWORD dwRecCount = 0 ;

char * SMTPCOMMANDS[]={"HELO", "MAIL FROM:","RCPT TO:", "DATA", "QUIT"};
// Default Time Out Values See RFC 1123.Sec.5.3.1
DWORD TimeOut[6]={18000000,18000000,18000000,7200000,10800000,36000000};
DWORD dwSndTO = 90000;

gethostname(szHostName,100);

try
{

SOCKADDR_IN SendSock;
SendSock.sin_family=AF_INET;
SendSock.sin_addr.s_addr= m_dwServerIP;
SendSock.sin_port=htons(PORT);

if ( (sSock=socket(AF_INET,SOCK_STREAM,0))==INVALID_SOCKET)
{
wsprintf(m_szErrorMsg,"SMTPSendMail::Socket creation failed");
return -1;
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Connect and Get Greeting SMTP ERROR CODE Success == 220 Failure = 421
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

if ((iErr=connect(sSock,( const struct sockaddr FAR *)&SendSock,sizeof (SendSock)))==SOCKET_ERROR)

{
wsprintf(m_szErrorMsg,"Connect Attempt failed to %s Server",m_lpszMailServer);
int code = WSAGetLastError (); // returns WSAECONNREFUSED
closesocket(sSock);
return -1;
}


iErr = setsockopt(sSock,SOL_SOCKET, SO_RCVTIMEO ,(char *)&TimeOut[0],sizeof(TimeOut[0]));
iErr = setsockopt(sSock,SOL_SOCKET, SO_SNDTIMEO ,(char *)&dwSndTO,sizeof(dwSndTO));

ZeroMemory(szRecvBuf,2000);
iErr = 0 ;
iCount = 0;

...
...
...
}
What is the problem?
Please help.

Thanks in advance.

rgds
Venkatesh




GeneralRe: Socket connect function fails and WSAGetLastError returns WSAECONNREFUSED in a WIN32 service Pin
Masaaki Onishi28-Nov-01 6:21
Masaaki Onishi28-Nov-01 6:21 
GeneralModeless Dialog without leakages Pin
Braulio Dez27-Nov-01 21:15
Braulio Dez27-Nov-01 21:15 
GeneralRe: Modeless Dialog without leakages Pin
Michael Dunn27-Nov-01 21:31
sitebuilderMichael Dunn27-Nov-01 21:31 
GeneralA simple problem for help Pin
27-Nov-01 21:11
suss27-Nov-01 21:11 
GeneralRe: A simple problem for help Pin
Eugene Pustovoyt27-Nov-01 21:18
Eugene Pustovoyt27-Nov-01 21:18 
GeneralRe: A simple problem for help Pin
27-Nov-01 21:46
suss27-Nov-01 21:46 
GeneralRe: A simple problem for help Pin
Eugene Pustovoyt27-Nov-01 22:41
Eugene Pustovoyt27-Nov-01 22:41 
GeneralGetCurrentDirectory problem on Windows 98 Pin
27-Nov-01 20:56
suss27-Nov-01 20:56 
GeneralRe: GetCurrentDirectory problem on Windows 98 Pin
Nish Nishant27-Nov-01 23:03
sitebuilderNish Nishant27-Nov-01 23:03 
GeneralRe: GetCurrentDirectory problem on Windows 98 Pin
27-Nov-01 23:21
suss27-Nov-01 23:21 
GeneralRe: GetCurrentDirectory problem on Windows 98 Pin
Jon Hulatt27-Nov-01 23:25
Jon Hulatt27-Nov-01 23:25 
GeneralRe: GetCurrentDirectory problem on Windows 98 Pin
Nish Nishant27-Nov-01 23:33
sitebuilderNish Nishant27-Nov-01 23:33 
GeneralRe: GetCurrentDirectory problem on Windows 98 Pin
27-Nov-01 23:53
suss27-Nov-01 23:53 
GeneralToolBar Alignment Pin
27-Nov-01 20:54
suss27-Nov-01 20:54 
GeneralRe: ToolBar Alignment Pin
Nish Nishant27-Nov-01 23:00
sitebuilderNish Nishant27-Nov-01 23:00 
GeneralRe: ToolBar Alignment Pin
Christian Graus27-Nov-01 23:35
protectorChristian Graus27-Nov-01 23:35 
GeneralFile Dialog Problem Pin
San27-Nov-01 20:11
San27-Nov-01 20:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.