|
I guess the pronlem is in your code, but I can't see it...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
What I'm doing wrong , because LPHOSTENT lpHostEnt is null :
SOCKET m_hSocket;
LPHOSTENT lpHostEnt;
CString sServer = "smtp.gmail.com";
lpHostEnt = gethostbyname(sServer);
if(lpHostEnt == NULL)AfxMessageBox("lpHostEnt is NULL");
|
|
|
|
|
There seems to be a problem with this address. Try accessing it via your browser to check if it is correct.
It's time for a new signature.
|
|
|
|
|
We don't know, but the runtime knows! use WSAGetLastError and check the error code.
|
|
|
|
|
A NULL return value usually means that you are looking up a non existent hostname. What does WSAGetLastError() return?
if(lpHostEnt == NULL)
{
CString sOutput;
sOutput.Format("Non existing hostname, error %d", ::WSAGetLastError());
AfxMessageBox(sOutput);
}
Chat in Europe Now with 24% more Twitter
modified on Thursday, May 6, 2010 3:47 AM
|
|
|
|
|
I will try this things , later , ( now I'm at job ) and surely reply ! Thank you !
|
|
|
|
|
As I promise , I'm back , here is error :
Non existing hostname, error 10093
And if I type smtp.gmail.com in address bar of my browser ( IE8 ) , I get no page ...
What should I do ?
|
|
|
|
|
According to MSDN 10093 means: Either the application has not called WSAStartup, or WSAStartup failed.
You need to call WSAStartup()[^] once in your application, see Winsock FAQ[^] for example code.
Hope this helps
|
|
|
|
|
Here is my entire code :
SOCKET CSmtp::ConnectRemoteServer(CString sServer, UINT nPort)
{
short nProtocolPort;
LPHOSTENT lpHostEnt;
LPSERVENT lpServEnt;
SOCKADDR_IN sockAddr;
SOCKET hServerSocket = INVALID_SOCKET;
struct in_addr addr;
if(atoi(sServer.Left(1)) == 0)lpHostEnt = gethostbyname(sServer);
else
{
addr.s_addr = inet_addr(sServer);
if(addr.s_addr == INADDR_NONE)
{
m_nError = CSMTP_BAD_IPV4_ADDR;
return INVALID_SOCKET;
}
else lpHostEnt = gethostbyaddr((char *)&addr,4,AF_INET);
}
if(lpHostEnt != NULL)
{
if((hServerSocket = socket(PF_INET,SOCK_STREAM,0)) != INVALID_SOCKET)
{
if(nPort)nProtocolPort = htons(nPort);
else
{
lpServEnt = getservbyname("mail",0);
if(lpServEnt == NULL)nProtocolPort = htons(25);
else nProtocolPort = lpServEnt->s_port;
}
sockAddr.sin_family = AF_INET;
sockAddr.sin_port = nProtocolPort;
sockAddr.sin_addr = *((LPIN_ADDR)*lpHostEnt->h_addr_list);
if(connect(hServerSocket,(PSOCKADDR)&sockAddr,sizeof(sockAddr)) == SOCKET_ERROR)
{
m_nError = CSMTP_WSA_CONNECT;
hServerSocket = INVALID_SOCKET;
}
}
else
{
m_nError = CSMTP_WSA_INVALID_SOCKET;
return INVALID_SOCKET;
}
}
else
{
m_nError = CSMTP_WSA_GETHOSTBY_NAME_ADDR;
return INVALID_SOCKET;
}
return hServerSocket;
}
and here I try :
CString sServer = "smtp.gmail.com";
if((m_hSocket = ConnectRemoteServer(sServer,25)) == INVALID_SOCKET)
{
m_nError = CSMTP_WSA_INVALID_SOCKET;
return FALSE;
}
modified on Thursday, May 6, 2010 12:13 PM
|
|
|
|
|
Is it safe to load dll compiled in Visual studio 2005 into application compiled in the Visual studio 6?
|
|
|
|
|
|
That depends on the interface of the DLL. If COM-dll or C-dll that static link to the CRT then no problem.
If exporting C++ interfaces that makes use of the STL or uses shared heap, then the DLL must be compiled using the same version of Visual Studio.
|
|
|
|
|
how to call srand(time(NULL));
When compile, I got:
: error C2064: term does not evaluate to a function
at the line:
srand(time(NULL));
Please help to identify what I missing?
|
|
|
|
|
try this:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main( void )
{
int i;
srand( (unsigned)time( NULL ) );
for( i = 0; i < 10;i++ )
printf( " %6d\n", rand() );
printf("\n");
{
int RANGE_MIN = 0;
int RANGE_MAX = 100;
for (i = 0; i < 10; i++ )
{
int rand100 = (((double) rand() /
(double) RAND_MAX) * RANGE_MAX + RANGE_MIN);
printf( " %6d\n", rand100);
}
}
}
|
|
|
|
|
Xing Chen wrote:
int rand100 = (((double) rand() /
(double) RAND_MAX) * RANGE_MAX + RANGE_MIN);
ftfy:
int rand100 = (((double) rand() /
(double) RAND_MAX) * (RANGE_MAX - RANGE_MIN) + RANGE_MIN);
Software rusts. Simon Stephenson, ca 1994.
modified on Thursday, May 6, 2010 3:17 AM
|
|
|
|
|
What exactly does casting the return value of time() to unsigned do to address the C2064 error?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I put you suggested. I got the same problem in my program.
I tested in a small program, it OK. Someconflict with my program.
Thanks
|
|
|
|
|
Hello everybody !
I want to transformation some numbers.
just like:
char szTemp[5] = "300";
1、How to convert szTemp to 8# value (300).
2、And then ,how to convert 8# 300 to 16# C0 ?
|
|
|
|
|
|
What does 8# and 16# represent? The radix, perhaps.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
hi,
i am doing vc++ course, i want to store the image in to an byte array that comes from web cam, after storing that data i want to display in to the server from byte stream. can any one help
thanks
|
|
|
|
|
Sure,
You get a byte stream from a webCam, & you'd like to display said image. Correct?
Well, I'll assume that your data is pointed to by *rawData and that the lines aren't padded (each horizontal line of the image consumes width*3 bytes)
wouldn't you just start-out by writing a few functions that will allow you to get all of the pixels one-by-one and insert them into a HBITMAP object?
As a start, how about something to get pixel values (watch for endianess)
COLORREF getPixelFromRawData(int x, int y)
{
char *data, r, g, b;
long index;
data = rawData;
index = (y*widthPixels*3) + (x*3)
r = data[index+0];
g = data[index+1];
b = data[index+2];
return RGB(r,g,b)
}
|
|
|
|
|
Hi,
I am reading a text file into my richedit ctrl via Streamin call back function
When I finish processing the files the Text is displayed in the RichEdit as if I had entered "SELECT ALL" from an Edit menu selection ...
thsnk
|
|
|
|
|
I would say yes to your statement, when you finished reading, the whole text is selected.
I suspect that your question is, how to unselect the text. Therefor call SetSel( 0, 0); member function of your CRichEditCtrl derived control after finishing reading.
|
|
|
|
|
That's it thankx also puts to the top of the text
|
|
|
|