petr petr - 4 months ago 40
C Question

IMAP server won't response

I try to create an IMAP client using sockets.
I successfully connect to server and receive welcome message but when trying to login and sending logging information(username and password) server won't response. Here is sample of my code:

b_send = send(client_socket, "a1 LOGIN username password", strlen("a1 LOGIN username password"), 0);
if (b_send < 0)
perror("ERROR in send");

printf("Sent, waiting for response.\n");

bzero(buf, BUFSIZE);
b_rcv = recv(client_socket, buf, BUFSIZE, 0);
if (b_rcv < 0)
perror("ERROR in rcv");

printf("Echo from server: %s", buf);

It print out "Sent, waiting for response." and nothing happens. What am i doing wrong?


You never sent the required "\r\n".

See section 2.2.

All interactions transmitted by client and server are in the form of
lines, that is, strings that end with a CRLF.

Also, why would you repeat your string like that? Put it in a variable.