2014-07-19 1 views
0

Je veux écrire un client de messagerie en C. J'utilise openssl, mais j'ai un problème que lorsque j'utilise la commande comme "exemple USER" qui fonctionne avec telnet, je reçois toujours un "inconnu commande "retour.C OpenSSL se connecter à POP Mail Server

Le code est nécessaire:

int login(BIO *bio) { 
unsigned char buf_print[4096]; //Used for WebPrintLine to 
unsigned char user_log[] = {"USER me\n"}; 

if(WebSendLine(bio, user_log, strlen(user_log)) != 0) { 
    printf("Couldn't login.\n"); 
    return -1; 
} 
WebPrintReturnLine(bio, buf_print, sizeof(buf_print));//Print the line to the display 
} 

Et:

//Send one line of data 
int WebSendLine(BIO *bio, unsigned char buf_write[], int strlenbuf) { 
/* 
BIO_write will attempt to write bytes to the socket. It returns the number of bytes actually written, or 0 or -1. As with BIO_read, 0 or -1 does not necessarily indicate an error. BIO_should_retry is the way to find out. If the write operation is to be retried, it must be   with the exact same parameters as before. 
*/ 
if(BIO_write(bio, buf_write, strlenbuf) <= 0) { 
    if(! BIO_should_retry(bio)) 
     return -1; 
    } 
return 0; 
} 

Je suis plus ou moins un débutant, donc je peut-être pas encore comprendre comment cela fonctionne vraiment, de toute façon. Ma question est qu'est-ce que je dois faire pour que je ne reçoive pas "commat inconnu" du serveur?

J'ai hâte d'avoir de vos nouvelles.

concernant roi, Greenality

Répondre

1

Le serveur attend un retour chariot et saut de ligne. Vous devriez envoyer "Exemple d'utilisateur \ r \ n"

Questions connexes