sgt.pepper
January 24th, 2005, 04:19 PM
Hello,
i've searched the forum but didn't found a solution for my problem.
I want to program a FTP client with special (no standart) commands. I'm using CAsyncSocket.
When i run my program in debug-modus with break point, everything is fine. But when i compile it, the program just shuts down...
May it runs too fast?
CAsyncSocket m_socket;
int test;
test = m_socket.Create(0,SOCK_STREAM,FD_ACCEPT);
if ( test == 0 ) {
printf( "Error at socket(): %ld\n", WSAGetLastError() );
WSACleanup();
return nRetCode;
}
if ( m_socket.Connect("ftp.domain.test", 21) == SOCKET_ERROR) {
printf( "Failed to connect.\n" );
printf("Error at socket(): %ld\n", WSAGetLastError());
WSACleanup();
return nRetCode;
}
// Send and receive data.
char sendbuf[1024] = "";
CString strInput;
int bytesSent;
int bytesRecv = SOCKET_ERROR;
const int bufferlength = 4096;
char recvbuf[bufferlength];
bool finished = false;
memset(recvbuf, 0, bufferlength);
bytesRecv = m_socket.Receive(recvbuf, bufferlength - 1, 0 );
recvbuf[bytesRecv] = 0;
printf( "%s", recvbuf );
// send login
strcpy(sendbuf,"USER anonymous\n\r");
int sendbufsize;
sendbufsize = strlen(sendbuf);
bytesRecv = m_socket.Send(sendbuf, sendbufsize, 0 );
memset(recvbuf, 0, bufferlength);
bytesRecv = m_socket.Receive(recvbuf, bufferlength - 1, 0 );
recvbuf[bytesRecv] = 0;
printf( "%s", recvbuf );
// send PW
strcpy(sendbuf,"PASS myemail\n\r");
m_socket.Send(sendbuf, sendbufsize, 0 );
i've searched the forum but didn't found a solution for my problem.
I want to program a FTP client with special (no standart) commands. I'm using CAsyncSocket.
When i run my program in debug-modus with break point, everything is fine. But when i compile it, the program just shuts down...
May it runs too fast?
CAsyncSocket m_socket;
int test;
test = m_socket.Create(0,SOCK_STREAM,FD_ACCEPT);
if ( test == 0 ) {
printf( "Error at socket(): %ld\n", WSAGetLastError() );
WSACleanup();
return nRetCode;
}
if ( m_socket.Connect("ftp.domain.test", 21) == SOCKET_ERROR) {
printf( "Failed to connect.\n" );
printf("Error at socket(): %ld\n", WSAGetLastError());
WSACleanup();
return nRetCode;
}
// Send and receive data.
char sendbuf[1024] = "";
CString strInput;
int bytesSent;
int bytesRecv = SOCKET_ERROR;
const int bufferlength = 4096;
char recvbuf[bufferlength];
bool finished = false;
memset(recvbuf, 0, bufferlength);
bytesRecv = m_socket.Receive(recvbuf, bufferlength - 1, 0 );
recvbuf[bytesRecv] = 0;
printf( "%s", recvbuf );
// send login
strcpy(sendbuf,"USER anonymous\n\r");
int sendbufsize;
sendbufsize = strlen(sendbuf);
bytesRecv = m_socket.Send(sendbuf, sendbufsize, 0 );
memset(recvbuf, 0, bufferlength);
bytesRecv = m_socket.Receive(recvbuf, bufferlength - 1, 0 );
recvbuf[bytesRecv] = 0;
printf( "%s", recvbuf );
// send PW
strcpy(sendbuf,"PASS myemail\n\r");
m_socket.Send(sendbuf, sendbufsize, 0 );